Use std::convert for AnyMap -> RawAnyMap.

This commit is contained in:
Chris Morgan 2015-03-26 09:46:51 +11:00
parent 97ec79029f
commit f3fb1c5562

View file

@ -1,6 +1,6 @@
//! This crate provides the `AnyMap` type, a safe and convenient store for one value of each type. //! This crate provides the `AnyMap` type, a safe and convenient store for one value of each type.
#![feature(core, std_misc)] #![feature(core, std_misc, convert)]
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]
#![warn(missing_docs, unused_results)] #![warn(missing_docs, unused_results)]
@ -172,44 +172,24 @@ impl AnyMap {
}), }),
} }
} }
}
/// Get a reference to the raw untyped map underlying the `AnyMap`. impl AsRef<RawAnyMap> for AnyMap {
/// fn as_ref(&self) -> &RawAnyMap {
/// Normal users will not need to use this, but generic libraries working with an `AnyMap` may
/// just find a use for it occasionally.
#[inline]
pub fn as_raw(&self) -> &RawAnyMap {
&self.raw &self.raw
} }
}
/// Get a mutable reference to the raw untyped map underlying the `AnyMap`. impl AsMut<RawAnyMap> for AnyMap {
/// fn as_mut(&mut self) -> &mut RawAnyMap {
/// Normal users will not need to use this, but generic libraries working with an `AnyMap` may
/// just find a use for it occasionally.
#[inline]
pub fn as_raw_mut(&mut self) -> &mut RawAnyMap {
&mut self.raw &mut self.raw
} }
}
/// Convert the `AnyMap` into the raw untyped map that underlyies it. impl Into<RawAnyMap> for AnyMap {
/// fn into(self) -> RawAnyMap {
/// Normal users will not need to use this, but generic libraries working with an `AnyMap` may
/// just find a use for it occasionally.
#[inline]
pub fn into_raw(self) -> RawAnyMap {
self.raw self.raw
} }
/// Convert a raw untyped map into an `AnyMap`.
///
/// Normal users will not need to use this, but generic libraries working with an `AnyMap` may
/// just find a use for it occasionally.
#[inline]
pub fn from_raw(raw: RawAnyMap) -> AnyMap {
AnyMap {
raw: raw,
}
}
} }
/// A view into a single occupied location in an `AnyMap`. /// A view into a single occupied location in an `AnyMap`.