llvm_scratch/core/llvm_string/
string.rs1use std::fmt;
2use std::fmt::Formatter;
3
4#[derive(Eq, PartialEq, PartialOrd, Ord, Hash, Clone)]
5pub struct LLVMString {
6 value: String,
7}
8
9impl LLVMString {
10 fn new(value: String) -> Self {
11 Self { value }
12 }
13 pub fn is_empty(&self) -> bool {
14 self.value.is_empty()
15 }
16}
17
18impl fmt::Display for LLVMString {
19 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
20 write!(f, "{}", self.value)
21 }
22}
23
24impl From<String> for LLVMString {
25 fn from(v: String) -> Self {
26 Self::new(v)
27 }
28}
29
30impl From<&str> for LLVMString {
31 fn from(v: &str) -> Self {
32 Self::new(v.to_string())
33 }
34}