summaryrefslogtreecommitdiffstats
path: root/third_party/rust/derive_more/tests/deref.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/derive_more/tests/deref.rs
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/derive_more/tests/deref.rs')
-rw-r--r--third_party/rust/derive_more/tests/deref.rs68
1 files changed, 68 insertions, 0 deletions
diff --git a/third_party/rust/derive_more/tests/deref.rs b/third_party/rust/derive_more/tests/deref.rs
new file mode 100644
index 0000000000..8227f88f98
--- /dev/null
+++ b/third_party/rust/derive_more/tests/deref.rs
@@ -0,0 +1,68 @@
+#![allow(dead_code, unused_imports)]
+#[macro_use]
+extern crate derive_more;
+
+#[derive(Deref)]
+#[deref(forward)]
+struct MyBoxedInt(Box<i32>);
+
+#[derive(Deref)]
+#[deref(forward)]
+struct NumRef<'a> {
+ num: &'a i32,
+}
+
+#[derive(Deref)]
+struct NumRef2<'a> {
+ #[deref(forward)]
+ num: &'a i32,
+ useless: bool,
+}
+
+#[derive(Deref)]
+#[deref(forward)]
+struct NumRef3<'a> {
+ num: &'a i32,
+ #[deref(ignore)]
+ useless: bool,
+}
+
+#[derive(Deref)]
+struct MyInt(i32);
+
+#[derive(Deref)]
+struct Point1D {
+ x: i32,
+}
+
+#[derive(Deref)]
+struct Point1D2 {
+ x: i32,
+ #[deref(ignore)]
+ useless: bool,
+}
+
+#[derive(Deref)]
+struct CoolVec {
+ cool: bool,
+ #[deref]
+ vec: Vec<i32>,
+}
+
+#[derive(Deref)]
+struct GenericVec<T>(Vec<T>);
+
+#[test]
+fn deref_generic() {
+ let gv = GenericVec(Vec::<i32>::new());
+ assert!(gv.is_empty())
+}
+
+#[derive(Deref)]
+struct GenericBox<T>(#[deref(forward)] Box<T>);
+
+#[test]
+fn deref_generic_forward() {
+ let boxed = GenericBox(Box::new(1i32));
+ assert_eq!(*boxed, 1i32);
+}