From: Chris Morgan Date: Wed, 25 Mar 2015 22:46:51 +0000 (+1100) Subject: Use std::convert for AnyMap -> RawAnyMap. X-Git-Tag: 0.9.13~1 X-Git-Url: https://git.chrismorgan.info/anymap/commitdiff_plain/f3fb1c5562204fa7e03cfe86595c50fdecd2910f Use std::convert for AnyMap -> RawAnyMap. --- diff --git a/src/lib.rs b/src/lib.rs index 8076981..acc0265 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ //! 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))] #![warn(missing_docs, unused_results)] @@ -172,44 +172,24 @@ impl AnyMap { }), } } +} - /// Get a reference to the raw untyped map underlying the `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 as_raw(&self) -> &RawAnyMap { +impl AsRef for AnyMap { + fn as_ref(&self) -> &RawAnyMap { &self.raw } +} - /// Get a mutable reference to the raw untyped map underlying the `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 as_raw_mut(&mut self) -> &mut RawAnyMap { +impl AsMut for AnyMap { + fn as_mut(&mut self) -> &mut RawAnyMap { &mut self.raw } +} - /// Convert the `AnyMap` into the raw untyped map that underlyies it. - /// - /// 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 { +impl Into for AnyMap { + fn into(self) -> RawAnyMap { 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`.