Add the DerefImm and DerefMut traits.
This commit is contained in:
parent
19fadf6567
commit
3b125ff3bb
3 changed files with 26 additions and 1 deletions
|
@ -232,6 +232,9 @@ lets_do_this! {
|
|||
ShrTraitLangItem, "shr", shr_trait;
|
||||
IndexTraitLangItem, "index", index_trait;
|
||||
|
||||
DerefTraitLangItem, "deref", deref_trait;
|
||||
DerefMutTraitLangItem, "deref_mut", deref_mut_trait;
|
||||
|
||||
EqTraitLangItem, "eq", eq_trait;
|
||||
OrdTraitLangItem, "ord", ord_trait;
|
||||
|
||||
|
|
|
@ -464,6 +464,28 @@ pub trait Index<Index,Result> {
|
|||
fn index(&self, index: &Index) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub trait Deref<Result> {
|
||||
fn deref<'a>(&'a self) -> &'a Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[lang="deref"]
|
||||
pub trait Deref<Result> {
|
||||
fn deref<'a>(&'a self) -> &'a Result;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub trait DerefMut<Result>: Deref<Result> {
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[lang="deref_mut"]
|
||||
pub trait DerefMut<Result>: Deref<Result> {
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut Result;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod bench {
|
||||
extern crate test;
|
||||
|
|
|
@ -23,7 +23,7 @@ generally useful to many Rust programs.
|
|||
pub use kinds::{Freeze, Pod, Send, Sized};
|
||||
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
|
||||
pub use ops::{BitAnd, BitOr, BitXor};
|
||||
pub use ops::{Drop};
|
||||
pub use ops::{Drop, Deref, DerefMut};
|
||||
pub use ops::{Shl, Shr, Index};
|
||||
pub use option::{Option, Some, None};
|
||||
pub use result::{Result, Ok, Err};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue