diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-12-01 12:12:41 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-12-13 13:50:40 -0600 |
| commit | e437e499d1ca9fa2dae69077358b3d1ffd06d27b (patch) | |
| tree | 781a7439cb81cf9ca4e2e8b540f14d8bb0c35ae0 /src/librustc_data_structures | |
| parent | 39e126c0013ca03a6b0abfcad7fdbe361e63b6e7 (diff) | |
| download | rust-e437e499d1ca9fa2dae69077358b3d1ffd06d27b.tar.gz rust-e437e499d1ca9fa2dae69077358b3d1ffd06d27b.zip | |
Implement Borrow/BorrowMut/ToOwned relationships betweed IdxSetBuf and IdxSet.
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/indexed_set.rs | 20 |
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() |
