]> git.proxmox.com Git - rustc.git/blame - src/test/ui/impl-trait/in-trait/success.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / impl-trait / in-trait / success.rs
CommitLineData
f2b60f7d
FG
1// check-pass
2
3#![feature(return_position_impl_trait_in_trait)]
4#![allow(incomplete_features)]
5
6use std::fmt::Display;
7
8trait Foo {
9 fn bar(&self) -> impl Display;
10}
11
12impl Foo for i32 {
13 fn bar(&self) -> i32 {
14 *self
15 }
16}
17
18impl Foo for &'static str {
19 fn bar(&self) -> &'static str {
20 *self
21 }
22}
23
24struct Yay;
25
26impl Foo for Yay {
27 fn bar(&self) -> String {
28 String::from(":^)")
29 }
30}
31
32fn foo_generically<T: Foo>(t: T) {
33 println!("{}", t.bar());
34}
35
36fn main() {
37 println!("{}", "Hello, world.".bar());
38 println!("The answer is {}!", 42.bar());
39 foo_generically(Yay);
40}