Skip to content

Commit f791b4f

Browse files
committed
Implement Borrow/BorrowMut/ToOwned relationships betweed IdxSetBuf and IdxSet.
1 parent e9e9abd commit f791b4f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/librustc_data_structures/indexed_set.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::borrow::{Borrow, BorrowMut, ToOwned};
1112
use std::fmt;
1213
use std::iter;
1314
use std::marker::PhantomData;
@@ -73,6 +74,25 @@ pub struct IdxSet<T: Idx> {
7374
bits: [Word],
7475
}
7576

77+
impl<T: Idx> Borrow<IdxSet<T>> for IdxSetBuf<T> {
78+
fn borrow(&self) -> &IdxSet<T> {
79+
&*self
80+
}
81+
}
82+
83+
impl<T: Idx> BorrowMut<IdxSet<T>> for IdxSetBuf<T> {
84+
fn borrow_mut(&mut self) -> &mut IdxSet<T> {
85+
&mut *self
86+
}
87+
}
88+
89+
impl<T: Idx> ToOwned for IdxSet<T> {
90+
type Owned = IdxSetBuf<T>;
91+
fn to_owned(&self) -> Self::Owned {
92+
IdxSet::to_owned(self)
93+
}
94+
}
95+
7696
impl<T: Idx> fmt::Debug for IdxSetBuf<T> {
7797
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
7898
w.debug_list()

0 commit comments

Comments
 (0)