Unnamed repository; edit this file 'description' to name the repository.
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::{borrow::Cow, sync::Arc},
    text_size::*,
};

#[derive(Copy, Clone)]
struct BadRope<'a>(&'a [&'a str]);

impl LenTextSize for BadRope<'_> {
    fn len_text_size(self) -> TextSize {
        self.0.iter().map(TextSize::of).sum()
    }
}

#[test]
fn main() {
    macro_rules! test {
        ($($expr:expr),+ $(,)?) => {
            $(let _ = TextSize::of($expr);)+
        };
    }

    test! {
        "",
        &"",
        'a',
        &'a',
        &String::new(),
        &String::new().into_boxed_str(),
        &Arc::new(String::new()),
        &Cow::Borrowed(""),
        BadRope(&[""]),
    }
}