Last active
October 16, 2015 03:38
-
-
Save erickt/aae745395d049eb0f8b8 to your computer and use it in GitHub Desktop.
multirust run nightly rustc --crate-type lib bar.rs && multirust run nightly rustc -L . foo.rs
This file contains hidden or 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
pub trait MyFrom2<T> { | |
fn my_from2(T) -> Self; | |
} |
This file contains hidden or 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
extern crate bar; | |
use std::convert::From; | |
use bar::MyFrom2; | |
struct MyVec(Vec<u8>); | |
impl<'a> From<&'a [u8]> for MyVec { | |
fn from(s: &[u8]) -> MyVec { | |
MyVec(s.to_owned()) | |
} | |
} | |
trait MyFrom<T> { | |
fn my_from(T) -> Self; | |
} | |
impl<'a> MyFrom<&'a [u8]> for MyVec { | |
fn my_from(s: &[u8]) -> MyVec { | |
MyVec(s.to_owned()) | |
} | |
} | |
impl<'a> MyFrom2<&'a [u8]> for MyVec { | |
fn my_from2(s: &[u8]) -> MyVec { | |
MyVec(s.to_owned()) | |
} | |
} | |
fn make(s: &[u8]) -> MyVec { | |
MyVec(s.to_owned()) | |
} | |
fn main() { | |
let _v = MyVec::from(&b"123"[..]); | |
// let _v = MyVec::from(b"123"); | |
// | |
// Error's with: | |
// foo.rs:27:14: 27:25 error: the trait `core::convert::From<&[u8; 3]>` is not implemented for the type `MyVec` [E0277] | |
// foo.rs:27 let _v = MyVec::from(b"123"); | |
// ^~~~~~~~~~~ | |
let _v = MyVec::my_from(&b"123"[..]); | |
let _v = MyVec::my_from(b"123"); | |
let _v = MyVec::my_from2(&b"123"[..]); | |
let _v = MyVec::my_from2(b"123"); | |
let _v = make(b"123"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment