just-string 2025.12.5

Container for various kinds of strings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::{borrow::Cow, ops::Add};

use crate::JustString;

impl<'x> Add<&'x str> for JustString<'x> {
    type Output = Self;

    fn add(self, rhs: &'x str) -> Self::Output {
        match self {
            Self::RefStr(s) => Self::CowStr(Cow::Borrowed(s) + rhs),
            Self::RefString(s) => Self::String(s.clone() + rhs),
            Self::CowStr(s) => Self::CowStr(s + rhs),
            Self::String(s) => Self::String(s + rhs),
            Self::BoxStr(s) => Self::BoxStr((s.to_string() + rhs).into_boxed_str()),
        }
    }
}