$ cargo test
Compiling fiz-math v0.0.12 (file:///home/stephen/Desktop/rust/mycrate)
src/lib.rs:4:13: 4:23 error: source trait is inaccessible
src/lib.rs:4 let v = x.to_foo().0;
^~~~~~~~~~
src/lib.rs:4:13: 4:23 note: module `foo` is private
src/lib.rs:4 let v = x.to_foo().0;
^~~~~~~~~~
error: aborting due to previous error
src/lib.rs:4:13: 4:23 error: source trait is inaccessible
src/lib.rs:4 let v = x.to_foo().0;
^~~~~~~~~~
src/lib.rs:4:13: 4:23 note: module `foo` is private
src/lib.rs:4 let v = x.to_foo().0;
^~~~~~~~~~
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
Could not compile `fiz-math`.
To learn more, run the command again with --verbose.
pub mod mymod;
pub fn foobar<T: mymod::ToFoo>(x: T) {
let v = x.to_foo().0;
}
mod foo;
pub use self::foo::{Foo, ToFoo};
pub trait ToFoo{
fn to_foo(self) -> Foo;
}
pub struct Foo(pub f32);
impl ToFoo for Foo {
fn to_foo(self) -> Foo { self }
}