/// Constructs an `NulStr` from a string slice.
///
/// # Correctness
///
/// If the string contains interior nuls,
/// the first nul will be considered the string terminator.
///
/// # Panics
///
/// This panics when the string does not end with `'\0'`.
///
/// # Example
///
/// ```rust
/// use abi_stable::sabi_types::NulStr;
///
/// const FOO: NulStr<'_> = NulStr::from_str("foo\0");
/// // `NulStr`s can be compared with `str`s
/// assert_eq!(FOO, "foo");
///
/// const BAR: NulStr<'_> = NulStr::from_str("bar\0");
/// assert_eq!(BAR, "bar");
///
/// const HEWWO: NulStr<'_> = NulStr::from_str("Hello, world!\0");
/// assert_eq!(HEWWO, "Hello, world!");
///
/// const TRUNCATED: NulStr<'_> = NulStr::from_str("baz\0world!\0");
/// assert_eq!(TRUNCATED, "baz");
///
/// ```
Constructs an `NulStr` from a string slice.
Constructs an ` NulStr ` from a string slice .
pub const fn from_str(str: &'a str) -> Self {
        let this = unsafe {
            Self {
                ptr: NonNull::new_unchecked(str.as_ptr() as *mut u8),
                _marker: PhantomData,
            }
        };
        let last_byte = str.as_bytes()[str.len() - 1] as usize;
        [this /* expected a nul terminator */][last_byte]
    }
pub const fn from_str ( str : & ' a str ) -> Self { let this = unsafe { Self { ptr : NonNull :: new_unchecked ( str . as_ptr ( ) as * mut u8 ) , _marker : PhantomData , } } ; let last_byte = str . as_bytes ( ) [ str . len ( ) - 1 ] as usize ; [ this /* expected a nul terminator */ ] [ last_byte ] }
Constructs an `NulStr` from a string slice.
Constructs an ` NulStr ` from a string slice .
str
&'a str
correctness
If the string contains interior nuls,
the first nul will be considered the string terminator.
If the string contains interior nuls the first nul will be considered the string terminator .
panics
This panics when the string does not end with `'\0'`.
This panics when the string does not end with ` ' \ 0 ' ` .
example
```rust
use abi_stable::sabi_types::NulStr.

const FOO: NulStr<'_> = NulStr::from_str("foo\0");
`NulStr`s can be compared with `str`s
assert_eq!(FOO, "foo").



const HEWWO: NulStr<'_> = NulStr::from_str("Hello, world!\0");
assert_eq!(HEWWO, "Hello, world!").

const TRUNCATED: NulStr<'_> = NulStr::from_str("baz\0world!\0");
assert_eq!(TRUNCATED, "baz").


` ` ` rust use abi_stable :: sabi_types :: NulStr . const FOO : NulStr< ' _ > = NulStr :: from_str ( " foo \ 0 " ) ; ` NulStr ` s can be compared with ` str ` s assert_eq! ( FOO " foo " ) . const HEWWO : NulStr< ' _ > = NulStr :: from_str ( " Hello world! \ 0 " ) ; assert_eq! ( HEWWO " Hello world! " ) . const TRUNCATED : NulStr< ' _ > = NulStr :: from_str ( " baz \ 0world! \ 0 " ) ; assert_eq! ( TRUNCATED " baz " ) .