mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
25 lines
452 B
Rust
25 lines
452 B
Rust
//@ run-pass
|
|
//@ aux-build:trait_safety_lib.rs
|
|
|
|
// Simple smoke test that unsafe traits can be compiled across crates.
|
|
|
|
|
|
extern crate trait_safety_lib as lib;
|
|
|
|
use lib::Foo;
|
|
|
|
struct Bar { x: isize }
|
|
unsafe impl Foo for Bar {
|
|
fn foo(&self) -> isize { self.x }
|
|
}
|
|
|
|
fn take_foo<F:Foo>(f: &F) -> isize { f.foo() }
|
|
|
|
fn main() {
|
|
let x: isize = 22;
|
|
assert_eq!(22, take_foo(&x));
|
|
|
|
let x: Bar = Bar { x: 23 };
|
|
assert_eq!(23, take_foo(&x));
|
|
}
|