summaryrefslogtreecommitdiffstats
path: root/vendor/derive_more/tests/index_mut.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/derive_more/tests/index_mut.rs')
-rw-r--r--vendor/derive_more/tests/index_mut.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/derive_more/tests/index_mut.rs b/vendor/derive_more/tests/index_mut.rs
new file mode 100644
index 000000000..a053fd332
--- /dev/null
+++ b/vendor/derive_more/tests/index_mut.rs
@@ -0,0 +1,36 @@
+#![allow(dead_code, unused_imports)]
+#[macro_use]
+extern crate derive_more;
+
+#[derive(IndexMut)]
+struct MyVec(Vec<i32>);
+//Index implementation is required for IndexMut
+impl<__IdxT> ::core::ops::Index<__IdxT> for MyVec
+where
+ Vec<i32>: ::core::ops::Index<__IdxT>,
+{
+ type Output = <Vec<i32> as ::core::ops::Index<__IdxT>>::Output;
+ #[inline]
+ fn index(&self, idx: __IdxT) -> &Self::Output {
+ <Vec<i32> as ::core::ops::Index<__IdxT>>::index(&self.0, idx)
+ }
+}
+
+#[derive(IndexMut)]
+struct Numbers {
+ #[index_mut]
+ numbers: Vec<i32>,
+ useless: bool,
+}
+
+//Index implementation is required for IndexMut
+impl<__IdxT> ::core::ops::Index<__IdxT> for Numbers
+where
+ Vec<i32>: ::core::ops::Index<__IdxT>,
+{
+ type Output = <Vec<i32> as ::core::ops::Index<__IdxT>>::Output;
+ #[inline]
+ fn index(&self, idx: __IdxT) -> &Self::Output {
+ <Vec<i32> as ::core::ops::Index<__IdxT>>::index(&self.numbers, idx)
+ }
+}