Skip to content

Commit

Permalink
Implement Borrow/BorrowMut/ToOwned relationships betweed IdxSetBuf an…
Browse files Browse the repository at this point in the history
…d IdxSet.
  • Loading branch information
pnkfelix committed Dec 13, 2017
1 parent 39e126c commit e437e49
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/librustc_data_structures/indexed_set.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e437e49

Please sign in to comment.