Re:Rust: Not So Great For Codec Implementing
by SilasX on Tuesday August 01, 2017 @02:21PM
(#14903724)
I meant primitives that preserve Rust's (safe) ownership model.
[ Parent
| on HN ]
Re:Rust: Not So Great For Codec Implementing
by geofft on Tuesday August 01, 2017 @02:54PM
(#14904083)
Well, you can use the existing split_at_mut if you're worried about getting your hand-rolled unsafe implementation wrong. It's definitely reasonable if you're splitting on rows; it may or may not be what you want if you're trying to get a slice-like thing that splits on columns.
(There's no reason to avoid safe functions that happen to have unsafe implementations. For instance, the standard-library implementation of indexing a slice, as in b"hello"[3], is just a bounds check plus an unsafe dereference.)