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

Function zeroize_string_entire_capacity

zeroize/tests/zeroize.rs:162–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160#[cfg(feature = "alloc")]
161#[test]
162fn zeroize_string_entire_capacity() {
163 let mut string = String::from("Hello, world!");
164 string.truncate(5);
165
166 string.zeroize();
167
168 // convert the string to a vec to easily access the unused capacity
169 let mut as_vec = string.into_bytes();
170 unsafe { as_vec.set_len(as_vec.capacity()) };
171
172 assert!(as_vec.iter().all(|byte| *byte == 0));
173}
174
175// TODO(tarcieri): debug flaky test (with potential UB?) See: RustCrypto/utils#774
176#[cfg(feature = "std")]

Callers

nothing calls this directly

Calls 1

zeroizeMethod · 0.45

Tested by

no test coverage detected