The post says The new API to cast in an unsafe manner is: let x: f32 = 1.0; let y: u8 = unsafe { x.to_int_unchecked() }; But as always, you should only use this method as a last resort. Just like with array access, the compiler can often optimize the checks away, making the safe and unsafe versions equivalent when the compiler can prove it. I believe for array access you can elide the bounds checking with an assert l…
It should be `assert!(len(arr) >= 255)` (greater instead of less than), right?
Rust 1.45
111–120 of 227 posts
Re: Rust 1.45
#112The post says The new API to cast in an unsafe manner is: let x: f32 = 1.0; let y: u8 = unsafe { x.to_int_unchecked() }; But as always, you should only use this method as a last resort. Just like with array access, the compiler can often optimize the checks away, making the safe and unsafe versions equivalent when the compiler can prove it. I believe for array access you can elide the bounds checking with an assert l…
It should be `assert!(len(arr) >= 255)` (greater instead of less than), right?
Re: Rust 1.45
#113Earlier quoted context omitted.
All you need for algotrading is to query an api. Rust would be a poor choice for that anyways, like using a semi truck to carry your bike around.
I was more thinking of correctness - static typing + memory safety would reduce likelihood of runtime errors.
I feel like static typing would get in the way there, making code more verbose and more difficult to prototype while running possibly thousands of backtests (e.g, to tune hyperparameters of your model) but if that your preference, by all means, Rust should be usable for that.
Re: Rust 1.45
#114Re: Rust 1.45
#115Earlier quoted context omitted.
When working with audio as an example, saturation is much less obnoxious than wraparound. You can potentially destroy speakers and your hearing that way.
Saturated addition is indeed the correct way to add two PCM streams together. Especially back in the 1980s and 1990s you'd get awful code that did things like averaging the two streams because wrapping sounds awful and the authors were ignorant of the theory and/or unaware that saturated addition is a thing. You can tell when somebody did this because it means playing silence makes everything else quieter, or worse t…
Re: Rust 1.45
#116Earlier quoted context omitted.
Sort of; we have more than nothing, but not a full thing. Some things are well specified. Some things are mostly specified. Some things are still very much up in the air.
Do you have specification of a memory model?
Re: Rust 1.45
#117Re: Rust 1.45
#118Earlier quoted context omitted.
Nope, you're right, it was me that got caught up by it. :) Thanks, I'll fix that now. https://github.com/rust-lang/blog.rust-lang.org/commit/fe241... (should roll out in a few minutes)
And this is why we need bounds checking.
Re: Rust 1.45
#119Earlier quoted context omitted.
The smallest Rust binary ever produced was 145 bytes. https://github.com/tormol/tiny-rust-executable That is a bit extreme but it demonstrates the lower bound. There's a lot of things you can do to drop sizes, depending on the specifics of what you're doing and the tradeoffs you want to make. Architecture support is where stuff gets tougher than size, to be honest. ARM stuff is well supported though, and is only goin…
> ARM stuff is well supported though FYI Rust (and Go) currently don’t work on the new Apple ARM macs. https://news.ycombinator.com/item?id=23856806
Re: Rust 1.45
#120https://github.com/SergioBenitez/Rocket on stable rust finally!
IMHO, it's a shame So Much time has been spent (~3 years ?) on async at the cost of basic features like multipart and CORS. But I understand it could be more fun for the devs :-)
Features like CORS are available via third party fairings, but I could see them being incorporated in the future in the `rocket_contrib` portion. I think the goal is to keep the overall framework pretty light and put more things into the `rocket_contrib` portion.