1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that coherence detects overlap when some of the types in the
12 // impls are projections of associated type. Issue #20624.
14 use std::marker::PhantomData;
17 pub struct Cow<'a, B: ?Sized>(PhantomData<(&'a (),B)>);
19 /// Trait for moving into a `Cow`
20 pub trait IntoCow<'a, B: ?Sized> {
21 /// Moves `self` into `Cow`
22 fn into_cow(self) -> Cow<'a, B>;
25 impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned {
27 fn into_cow(self) -> Cow<'a, B> {
32 impl<'a, B: ?Sized> IntoCow<'a, B> for <B as ToOwned>::Owned where B: ToOwned {
34 fn into_cow(self) -> Cow<'a, B> {
39 impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned {
40 fn into_cow(self) -> Cow<'a, B> {
46 type Owned = &'static u8;
47 fn to_owned(&self) -> &'static u8 { panic!() }
50 /// A generalization of Clone to borrowed data.
54 /// Create owned data from borrowed data, usually by copying.
55 fn to_owned(&self) -> Self::Owned;