/// Creates a null-terminated UTF-8 string stored in a byte array into a String.
///
/// # Arguments
///
/// * `arr` - Array to read the UTF-8 string from.
///
/// # Examples
///
/// ```rust
/// let array: [u8; 18] = [b'H',b'e',b'l',b'l',b'o',b' ',b'W',b'o',b'r',b'l',b'd',b'!',b'\0',
///                        b'Z',b'a',b'l',b'g',b'o'];
/// assert_eq!(array_to_string(&array), String::from("Hello World!"));
/// ```
Creates a null-terminated UTF-8 string stored in a byte array into a String.
Creates a null - terminated UTF - 8 string stored in a byte array into a String .
pub fn array_to_string(arr: &[u8]) -> String {
    let bin: String = String::from_utf8(Vec::from(arr)).unwrap_or(String::new());
    match bin.find('\0') {
        Some(at) => String::from(bin.split_at(at).0),
        None     => bin
    }
}
pub fn array_to_string ( arr : & [ u8 ] ) -> String { let bin : String = String :: from_utf8 ( Vec :: from ( arr ) ) . unwrap_or ( String :: new ( ) ) ; match bin . find ( '\0' ) { Some ( at ) => String :: from ( bin . split_at ( at ) . 0 ) , None => bin } }
Creates a null-terminated UTF-8 string stored in a byte array into a String.
Creates a null - terminated UTF - 8 string stored in a byte array into a String .
arr
&[u8]
examples
None