Skip to content

Instantly share code, notes, and snippets.

@Meyermagic
Created April 14, 2014 10:44
Show Gist options
  • Save Meyermagic/10636908 to your computer and use it in GitHub Desktop.
Save Meyermagic/10636908 to your computer and use it in GitHub Desktop.
extern crate othercrate = "othercrate#0.1.0";
use std::intrinsics::TypeId;
use othercrate::other::{Foo, foo_id};
fn main() {
println!("Foo's TypeId from this crate: {}", TypeId::of::<Foo>());
println!("Foo's TypeId from othercrate: {}", foo_id());
}
.PHONY : all
all: thiscrate
.PHONY : thiscrate
thiscrate: libothercrate
rustc -L . -O main.rs
.PHONY : libothercrate
libothercrate:
rustc -O --crate-type=rlib --out-dir . othercrate/lib.rs
#![crate_id = "othercrate#0.1.0"]
#![crate_type = "lib"]
pub mod other;
use std::intrinsics::TypeId;
pub enum Foo {
VarA(uint),
VarB(uint, uint)
}
pub fn foo_id() -> TypeId {
TypeId::of::<Foo>()
}
@Meyermagic
Copy link
Author

Prints
Foo's TypeId from this crate: TypeId { t: 17870372292551777611 }
Foo's TypeId from othercrate: TypeId { t: 15921533803692407670 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment