1
Fork 0

Add the DerefImm and DerefMut traits.

This commit is contained in:
Eduard Burtescu 2014-02-26 23:02:35 +02:00
parent 19fadf6567
commit 3b125ff3bb
3 changed files with 26 additions and 1 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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};