mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-30 20:44:34 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
		
			389 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			389 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| pub trait Foo {
 | |
|     type Associated;
 | |
| }
 | |
| 
 | |
| pub struct X;
 | |
| pub struct Y;
 | |
| 
 | |
| 
 | |
| impl Foo for X {
 | |
|     type Associated = ();
 | |
| }
 | |
| 
 | |
| impl Foo for Y {
 | |
|     type Associated = ();
 | |
| }
 | |
| 
 | |
| impl X {
 | |
|     pub fn returns_sized<'a>(&'a self) -> impl Foo<Associated=()> + 'a {
 | |
|         X
 | |
|     }
 | |
| }
 | |
| 
 | |
| impl Y {
 | |
|     pub fn returns_unsized<'a>(&'a self) -> Box<impl ?Sized + Foo<Associated=()> + 'a> {
 | |
|         Box::new(X)
 | |
|     }
 | |
| }
 | 
