forked from chris-morgan/anymap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.10.0: move Clone functionality into a feature.
No more separate Git branch for it; Cargo features fit the bill well.
- Loading branch information
1 parent
e84d584
commit c6480a9
Showing
7 changed files
with
149 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "anymap" | ||
version = "0.9.13" | ||
version = "0.10.0" | ||
authors = ["Chris Morgan <[email protected]>"] | ||
description = "A safe and convenient store for one value of each type" | ||
#documentation = "http://www.rust-ci.org/chris-morgan/anymap/doc/anymap/index.html" | ||
|
@@ -9,3 +9,6 @@ repository = "https://github.com/chris-morgan/anymap" | |
readme = "README.md" | ||
keywords = ["container", "data-structure", "map"] | ||
license = "MIT/Apache-2.0" | ||
|
||
[features] | ||
clone = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use std::any::Any; | ||
use raw::Any; | ||
use std::mem; | ||
use std::raw::TraitObject; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::fmt; | ||
|
||
#[doc(hidden)] | ||
pub trait CloneToAny { | ||
/// Clone `self` into a new `Box<Any>` object. | ||
fn clone_to_any(&self) -> Box<Any>; | ||
} | ||
|
||
impl<T: 'static + Clone> CloneToAny for T { | ||
fn clone_to_any(&self) -> Box<Any> { | ||
Box::new(self.clone()) | ||
} | ||
} | ||
|
||
#[doc(hidden)] | ||
/// Pretty much just `std::any::Any + Clone`. | ||
pub trait Any: ::std::any::Any + CloneToAny { } | ||
|
||
impl<T: 'static + Clone> Any for T { } | ||
|
||
impl Clone for Box<Any> { | ||
fn clone(&self) -> Box<Any> { | ||
(**self).clone_to_any() | ||
} | ||
} | ||
|
||
impl<'a> fmt::Debug for &'a Any { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.pad("&Any") | ||
} | ||
} | ||
|
||
impl<'a> fmt::Debug for Box<Any> { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.pad("Box<Any>") | ||
} | ||
} |