MCPcopy Create free account
hub / github.com/RustCrypto/utils / zeroize_string_entire_capacity

Function zeroize_string_entire_capacity

zeroize/tests/zeroize.rs:174–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172#[cfg(feature = "alloc")]
173#[test]
174fn zeroize_string_entire_capacity() {
175 let mut string = String::from("Hello, world!");
176 string.truncate(5);
177
178 string.zeroize();
179
180 // convert the string to a vec to easily access the unused capacity
181 let mut as_vec = string.into_bytes();
182 unsafe { as_vec.set_len(as_vec.capacity()) };
183
184 assert!(as_vec.iter().all(|byte| *byte == 0));
185}
186
187// TODO(tarcieri): debug flaky test (with potential UB?) See: RustCrypto/utils#774
188#[cfg(feature = "std")]

Callers

nothing calls this directly

Calls 1

zeroizeMethod · 0.45

Tested by

no test coverage detected