update to reflect changes recommended by @shepmaster his review
This commit is contained in:
parent
7dd078f53f
commit
ea68b3ff3d
1 changed files with 9 additions and 16 deletions
|
|
@ -1,30 +1,23 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// This test relies on `TryFrom` being auto impl for all `T: Into`
|
||||
// and `TryInto` being auto impl for all `U: TryFrom`
|
||||
// This test relies on `TryFrom` being blanket impl for all `T: Into`
|
||||
// and `TryInto` being blanket impl for all `U: TryFrom`
|
||||
|
||||
// This test was added to show the motivation for doing this
|
||||
// over `TryFrom` being auto impl for all `T: From`
|
||||
// over `TryFrom` being blanket impl for all `T: From`
|
||||
|
||||
#![feature(try_from, never_type)]
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
struct Foo<T> {
|
||||
t: T
|
||||
t: T,
|
||||
}
|
||||
|
||||
/*
|
||||
// This fails to compile due to coherence restrictions
|
||||
// as of rust version 1.32.x
|
||||
// as of Rust version 1.32.x, therefore it could not be used
|
||||
// instead of the `Into` version of the impl, and serves as
|
||||
// motivation for a blanket impl for all `T: Into`, instead
|
||||
// of a blanket impl for all `T: From`
|
||||
/*
|
||||
impl<T> From<Foo<T>> for Box<T> {
|
||||
fn from(foo: Foo<T>) -> Box<T> {
|
||||
Box::new(foo.t)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue