Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'lib/text-size/tests/constructors.rs')
-rw-r--r--lib/text-size/tests/constructors.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/text-size/tests/constructors.rs b/lib/text-size/tests/constructors.rs
new file mode 100644
index 0000000000..eba587b539
--- /dev/null
+++ b/lib/text-size/tests/constructors.rs
@@ -0,0 +1,31 @@
+use {
+ std::{borrow::Cow, ops::Deref},
+ text_size::*,
+};
+
+struct StringLike<'a>(&'a str);
+
+impl Deref for StringLike<'_> {
+ type Target = str;
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+#[test]
+fn main() {
+ let s = "";
+ let _ = TextSize::of(&s);
+
+ let s = String::new();
+ let _ = TextSize::of(&s);
+
+ let s = Cow::Borrowed("");
+ let _ = TextSize::of(&s);
+
+ let s = Cow::Owned(String::new());
+ let _ = TextSize::of(&s);
+
+ let s = StringLike("");
+ let _ = TextSize::of(&s);
+}