We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
fill
1 parent eaf6f46 commit 3838301Copy full SHA for 3838301
library/core/src/slice/specialize.rs
@@ -1,6 +1,3 @@
1
-use crate::mem::{size_of, transmute_copy};
2
-use crate::ptr::write_bytes;
3
-
4
pub(super) trait SpecFill<T> {
5
fn spec_fill(&mut self, value: T);
6
}
@@ -19,17 +16,8 @@ impl<T: Clone> SpecFill<T> for [T] {
19
16
20
17
impl<T: Copy> SpecFill<T> for [T] {
21
18
fn spec_fill(&mut self, value: T) {
22
- if size_of::<T>() == 1 {
23
- // SAFETY: The size_of check above ensures that values are 1 byte wide, as required
24
- // for the transmute and write_bytes
25
- unsafe {
26
- let value: u8 = transmute_copy(&value);
27
- write_bytes(self.as_mut_ptr(), value, self.len());
28
- }
29
- } else {
30
- for item in self.iter_mut() {
31
- *item = value;
32
+ for item in self.iter_mut() {
+ *item = value;
33
34
35
0 commit comments