Re:Rust: Not So Great For Codec Implementing
by dbaupp on Tuesday August 01, 2017 @01:24PM
(#14903106)
Yes, unsafe blocks one way in which the Rust doesn't privilege built-ins and the standard library (much) over external code: people can write high performance a abstractions without them needing to be baked into the language. This is exactly what has occurred with multidimensional arrays with external libraries like ndarray.
Re:Rust: Not So Great For Codec Implementing
by jeeyoungk on Tuesday August 01, 2017 @01:21PM
(#14903066)
Unsafe allows you to dereference raw pointers and foreign-function calls, but you cannot go around the borrow checker, which is what's causing annoyance.
That said, you can create raw and dereference raw pointers, which lets you to do the above.
Re:Rust: Not So Great For Codec Implementing
by vvanders on Tuesday August 01, 2017 @01:24PM
(#14903103)
If you take a ref into a pointer that lets you work around the borrow checker(and I've bitten myself just about every time I've done it now that I'm used to the borrow checker).
Re:Rust: Not So Great For Codec Implementing
by wuch on Tuesday August 01, 2017 @01:54PM
(#14903417)
Using unsafe blocks and pointers can silence the borrow checker, but that doesn't mean that code is well defined.
For example, using swap (mentioned in the article) with overlapping references would be undefined behaviour.
I've only looked into Rust briefly, but I thought this was the point of unsafe blocks? You can roll your own multi-dimensional array data structure using unsafe blocks if you're certain what you're doing is actually safe.