summaryrefslogtreecommitdiffstats
path: root/vendor/text-size/tests/constructors.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/text-size/tests/constructors.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/text-size/tests/constructors.rs')
-rw-r--r--vendor/text-size/tests/constructors.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/text-size/tests/constructors.rs b/vendor/text-size/tests/constructors.rs
new file mode 100644
index 000000000..9ff4e19c6
--- /dev/null
+++ b/vendor/text-size/tests/constructors.rs
@@ -0,0 +1,24 @@
+use text_size::TextSize;
+
+#[derive(Copy, Clone)]
+struct BadRope<'a>(&'a [&'a str]);
+
+impl BadRope<'_> {
+ fn text_len(self) -> TextSize {
+ self.0.iter().copied().map(TextSize::of).sum()
+ }
+}
+
+#[test]
+fn main() {
+ let x: char = 'c';
+ let _ = TextSize::of(x);
+
+ let x: &str = "hello";
+ let _ = TextSize::of(x);
+
+ let x: &String = &"hello".into();
+ let _ = TextSize::of(x);
+
+ let _ = BadRope(&[""]).text_len();
+}