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 …
hahaha, making contributions to std is super daunting to me though. But think this one should be small enough that it's feasible?
-
-
Maybe just a PR to add it next to "copy_from_slice" as two impls: `.copy_to_slice<T: Copy>(&mut self, item: T)` and `clone_to_slice<T: Clone>(&mut self, item: T)`? I think that would be a pretty consistent interface, both should reasonably lower appropriately.
-
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.
- 5 more replies
New conversation -
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.