non_empty_string/trait_impls/
mod.rs

1use std::borrow::Borrow;
2
3mod delegated_traits;
4
5use crate::NonEmptyString;
6
7#[cfg(not(no_global_oom_handling))]
8impl From<char> for NonEmptyString {
9    #[inline]
10    fn from(c: char) -> Self {
11        let string = c.to_string();
12        NonEmptyString::new(string).expect("since there is a singular char, the string will not be empty as it will contain exactly one char")
13    }
14}
15
16// Defined in the file for [`str`], not [`String`]
17impl Borrow<str> for NonEmptyString {
18    fn borrow(&self) -> &str {
19        <String as Borrow<str>>::borrow(&self.0)
20    }
21}
22
23impl Borrow<String> for NonEmptyString {
24    fn borrow(&self) -> &String {
25        &self.0
26    }
27}