Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/libstd/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use cast::transmute;
use cmp::Eq;
use option::{Option, Some, None};
use to_bytes::{IterBytes, Cb};
use to_str::ToStr;
use unstable::intrinsics;
use util::Void;
Expand Down Expand Up @@ -42,6 +43,12 @@ impl Eq for TypeId {
}
}

impl IterBytes for TypeId {
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
self.t.iter_bytes(lsb0, f)
}
}

///////////////////////////////////////////////////////////////////////////////
// Any trait
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -175,6 +182,7 @@ mod tests {
use super::*;
use super::AnyRefExt;
use option::{Some, None};
use hash::Hash;

#[deriving(Eq)]
struct Test;
Expand All @@ -197,6 +205,13 @@ mod tests {
assert_eq!(c, f);
}

#[test]
fn type_id_hash() {
let (a, b) = (TypeId::of::<uint>(), TypeId::of::<uint>::());

assert_eq!(a.hash(), b.hash());
}

#[test]
fn any_as_void_ptr() {
let (a, b, c) = (~5u as ~Any, ~TEST as ~Any, ~Test as ~Any);
Expand Down