1 #![deny(fallible_impl_from)]
5 impl From<String> for Foo {
6 fn from(s: String) -> Self {
7 Foo(s.parse().unwrap())
12 struct Valid(Vec<u8>);
14 impl<'a> From<&'a str> for Valid {
15 fn from(s: &'a str) -> Valid {
16 Valid(s.to_owned().into_bytes())
19 impl From<usize> for Valid {
20 fn from(i: usize) -> Valid {
21 Valid(Vec::with_capacity(i))
28 impl From<usize> for Invalid {
29 fn from(i: usize) -> Invalid {
37 impl From<Option<String>> for Invalid {
38 fn from(s: Option<String>) -> Invalid {
42 } else if s.parse::<u32>().unwrap() != 42 {
52 impl<T> ProjStrTrait for Box<T> {
53 type ProjString = String;
55 impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
56 fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
57 if s.parse::<u32>().ok().unwrap() != 42 {
66 impl From<String> for Unreachable {
67 fn from(s: String) -> Unreachable {
71 match s.chars().next() {
72 Some(_) => Unreachable,
73 None => unreachable!(), // do not lint the unreachable macro