Wrote a quick new crate today: slice-fill. Fills a slice with a value; easier to write than writing a manual loop. Might actually want to propose this for std since for u8/u16 it already optimizes to a memset(3), which is very fast already. https://docs.rs/slice-fill/1.0.1/slice_fill/index.html …
Those APIs confuse me? Would imagine "copy to slice" means "self" is copied to a slice. But the subject being copied is actually "item". Also Clone implies Copy; not sure I follow the difference? Essentially I'm proposing porting https://en.cppreference.com/w/cpp/algorithm/fill … directly to Rust.
-
-
Fair! Despite my bikeshedding, I think they would be useful to have as part of the slice impls! (I was going for symmetry with `copy_from_slice` and `clone_from_slice`), which are the facades over memcpy. https://doc.rust-lang.org/std/primitive.slice.html#method.copy_from_slice …
-
heh, interesting. Didn't know both methods existed with potential perf implications. TIL, thanks for sharing!
- 3 more replies
New conversation -
-
-
IIRC the reason copy_from_slice / clone_from_slice both exist was for cases where you'd want the guarantee that it was using the Copy implementation, I believe. I think this API went through the RFC process, so you can find some discussion there (can't bring it up rn, sorry).
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.