@@ -11,9 +11,10 @@ use core::str::Utf8Error;
1111/// Error type describing failures when parsing the string from a tag.
1212#[ derive( Debug , PartialEq , Eq , Clone ) ]
1313pub enum StringError {
14- /// There is no terminating null-byte, although the spec requires one.
15- MissingNull ( core:: ffi:: FromBytesUntilNulError ) ,
16- /// The sequence until the first NULL byte is not valid UTF-8.
14+ /// There is no terminating NUL character, although the specification
15+ /// requires one.
16+ MissingNul ( core:: ffi:: FromBytesUntilNulError ) ,
17+ /// The sequence until the first NUL character is not valid UTF-8.
1718 Utf8 ( Utf8Error ) ,
1819}
1920
@@ -27,7 +28,7 @@ impl Display for StringError {
2728impl core:: error:: Error for StringError {
2829 fn source ( & self ) -> Option < & ( dyn core:: error:: Error + ' static ) > {
2930 match self {
30- StringError :: MissingNull ( e) => Some ( e) ,
31+ StringError :: MissingNul ( e) => Some ( e) ,
3132 StringError :: Utf8 ( e) => Some ( e) ,
3233 }
3334 }
@@ -66,8 +67,7 @@ impl Tag {
6667 /// Parses the provided byte sequence as Multiboot string, which maps to a
6768 /// [`str`].
6869 pub fn parse_slice_as_string ( bytes : & [ u8 ] ) -> Result < & str , StringError > {
69- let cstr =
70- core:: ffi:: CStr :: from_bytes_until_nul ( bytes) . map_err ( StringError :: MissingNull ) ?;
70+ let cstr = core:: ffi:: CStr :: from_bytes_until_nul ( bytes) . map_err ( StringError :: MissingNul ) ?;
7171
7272 cstr. to_str ( ) . map_err ( StringError :: Utf8 )
7373 }
@@ -148,7 +148,7 @@ mod tests {
148148 // empty slice is invalid
149149 assert ! ( matches!(
150150 Tag :: parse_slice_as_string( & [ ] ) ,
151- Err ( StringError :: MissingNull ( _) )
151+ Err ( StringError :: MissingNul ( _) )
152152 ) ) ;
153153 // empty string is fine
154154 assert_eq ! ( Tag :: parse_slice_as_string( & [ 0x00 ] ) , Ok ( "" ) ) ;
@@ -160,7 +160,7 @@ mod tests {
160160 // reject missing null
161161 assert ! ( matches!(
162162 Tag :: parse_slice_as_string( b"hello" ) ,
163- Err ( StringError :: MissingNull ( _) )
163+ Err ( StringError :: MissingNul ( _) )
164164 ) ) ;
165165 // must not include final null
166166 assert_eq ! ( Tag :: parse_slice_as_string( b"hello\0 " ) , Ok ( "hello" ) ) ;
0 commit comments