about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_data_structures/indexed_set.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs
index 5d7139507b3..223e08de826 100644
--- a/src/librustc_data_structures/indexed_set.rs
+++ b/src/librustc_data_structures/indexed_set.rs
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::borrow::{Borrow, BorrowMut, ToOwned};
 use std::fmt;
 use std::iter;
 use std::marker::PhantomData;
@@ -73,6 +74,25 @@ pub struct IdxSet<T: Idx> {
     bits: [Word],
 }
 
+impl<T: Idx> Borrow<IdxSet<T>> for IdxSetBuf<T> {
+    fn borrow(&self) -> &IdxSet<T> {
+        &*self
+    }
+}
+
+impl<T: Idx> BorrowMut<IdxSet<T>> for IdxSetBuf<T> {
+    fn borrow_mut(&mut self) -> &mut IdxSet<T> {
+        &mut *self
+    }
+}
+
+impl<T: Idx> ToOwned for IdxSet<T> {
+    type Owned = IdxSetBuf<T>;
+    fn to_owned(&self) -> Self::Owned {
+        IdxSet::to_owned(self)
+    }
+}
+
 impl<T: Idx> fmt::Debug for IdxSetBuf<T> {
     fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
         w.debug_list()