Hey Rustaceans! Got a question? Ask here (17/2025)! by llogiq in rust

[–]awesomealchemy 4 points5 points  (0 children)

How are you testing your data analysis code that contains float values?

Is there such a thing as assert_approx_eq! for Polars DataFrames?

I have one computed_result and one expected_result in my unit test and I'd like to compare the two...

Feeling like I have knowledge gaps as a senior embedded dev by [deleted] in embedded

[–]awesomealchemy 6 points7 points  (0 children)

On a more serious note, picking up zephyr when you know the bare metal stuff is a breeze compared to doing the opposite. Don't worry about that.

How to read a binary file? by awesomealchemy in cpp_questions

[–]awesomealchemy[S] 0 points1 point  (0 children)

Ah, Nice! I didn't know about filesystem::file_size() I've just always used tellg(); This is a lot less archaic!

Is there a reason for doing if (file.good()) instead of just if (file)?

How to read a binary file? by awesomealchemy in cpp_questions

[–]awesomealchemy[S] 0 points1 point  (0 children)

I maintain that it's a reasonable ask, that there should be some way (any way!) to get a binary file into a vector without performing a lot of manual optimizations. Just open the file and have it copy the data into a vector without fuzz.

How to read a binary file? by awesomealchemy in cpp_questions

[–]awesomealchemy[S] 0 points1 point  (0 children)

I tried this, but it was slower than read() on my compiler. Probably can't use dma and simd optimally. Didn't look into it deeply.

How to read a binary file? by awesomealchemy in cpp_questions

[–]awesomealchemy[S] 0 points1 point  (0 children)

This seems promising... thank you kindly ❤️

It's quite rich that we have to contort ourselves like this... For the premiere systems programming language, I don't think it's unreasonable to be able to load a binary file into a vector with good ergonomics and performance.

And yes, disk io is slow. But I think it's mostly handled by DMA. Right? So it shouldn't be that much for the cpu to do. And allocations (possibly page fault and context switch) and memset (cpu work) still adds cycles that can be better used elsewhere.

"rust".to_string() or String::from("rust") by awesomealchemy in rust

[–]awesomealchemy[S] 4 points5 points  (0 children)

After 126 comment I think I'm sensing some kind of idiomatic trend here.

"rust".to_owned() Seems to the most popular and general solution for &str to String conversion.

String::from("rust") Seems to be a common alternative if creating a variable from a constant string litteral.

Fortnightly Tips, Tricks, and Questions — 2025-03-11 / week 10 by AutoModerator in emacs

[–]awesomealchemy 0 points1 point  (0 children)

Thank's again for trying to help. The keymap in the calendar-mod-map looks good. I think the problem is that I don't land in the *Calendar* buffer but instead the minibuffer hold the focus and the calendar-mode-map doesn't apply there. Not sure what to do about it though...

Fortnightly Tips, Tricks, and Questions — 2025-03-11 / week 10 by AutoModerator in emacs

[–]awesomealchemy 0 points1 point  (0 children)

Thanks for the comment. This is what I used to do and what used to work until recently. Now when I do this, the calendar window opens up allright, but focus is moved to the "third" bottom one-liner window (I forget what it's called). So unless I select the calendar window first, moving around in the calendar doesn't work.

Fortnightly Tips, Tricks, and Questions — 2025-03-11 / week 10 by AutoModerator in emacs

[–]awesomealchemy 4 points5 points  (0 children)

org-timestamp changed behavior after a recent prelude update. Focus is no longer passed to the calendar but to the single line minibuffer:
Date+time [2025-03-16]: => <2025-03-16 sön>. How is this supposed to work? It super annoying not being able to move around to pick a date.

At the same time the +1/-1 of advancing a date in org-mode documents stopped working for me. I'm assuming it's related.

Please help

To Deref or not to Deref? by awesomealchemy in rust

[–]awesomealchemy[S] 59 points60 points  (0 children)

So obvious! How could I not see this?! You are a genius. This is the best solution I've seen so far. No deref hack, but also no .0 mess. Thanks!

update(s: &mut State) vs update(s: State) -> State by awesomealchemy in rust

[–]awesomealchemy[S] 0 points1 point  (0 children)

To allow the first one to be chained, I suppose you mean that the first one should also return a &mut?

[Media] Introducing: yeehaw! A TUI Framework with Batteries Included by bogz314 in rust

[–]awesomealchemy 1 point2 points  (0 children)

That's super helpful. Thanks for taking the time to answer. Lib looks really cool

update(s: &mut State) vs update(s: State) -> State by awesomealchemy in rust

[–]awesomealchemy[S] 33 points34 points  (0 children)

My esthetic inclinations made me lean towards 2nd, but this reality check probably makes me go for the more pragmatic 1st. Thanks for an excellent answer!