1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::fmt;
use std::fmt::Formatter;

#[derive(Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct LLVMString {
    value: String,
}

impl LLVMString {
    fn new(value: String) -> Self {
        Self { value }
    }
    pub fn is_empty(&self) -> bool {
        self.value.is_empty()
    }
}

impl fmt::Display for LLVMString {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.value)
    }
}

impl From<String> for LLVMString {
    fn from(v: String) -> Self {
        Self::new(v)
    }
}

impl From<&str> for LLVMString {
    fn from(v: &str) -> Self {
        Self::new(v.to_string())
    }
}