Skip to content

Commit f125094

Browse files
committed
Add assertion for TextSized impls
1 parent be985b7 commit f125094

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/traits.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,23 @@ impl TextSized for char {
3434
(self.len_utf8() as u32).into()
3535
}
3636
}
37+
38+
// assertion shape from static_assertions::assert_impl_all!
39+
const _: fn() = || {
40+
use std::borrow::Cow;
41+
42+
fn assert_impl<T: TextSized>() {}
43+
44+
assert_impl::<&String>();
45+
assert_impl::<&Cow<str>>();
46+
47+
struct StringLike {}
48+
impl Deref for StringLike {
49+
type Target = str;
50+
fn deref(&self) -> &str {
51+
unreachable!()
52+
}
53+
}
54+
55+
assert_impl::<&StringLike>();
56+
};

0 commit comments

Comments
 (0)