Function pelite::util::strn [−][src]
pub fn strn(buf: &[u8]) -> &[u8]
Reads an optionally nul-terminated string from byte buffer.
Returns the slice split before the nul byte and the whole slice if no nul byte is found.
Analog to the strn*
family of C string functions.
Examples
use pelite::util::strn; let buf: &[u8; 8] = b"STRING\0\0"; assert_eq!(strn(buf), b"STRING"); let buf: &[u8; 4] = b"FOUR"; assert_eq!(strn(buf), b"FOUR");