Skip to content

example1 #81009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tariqjamil-bwp opened this issue Jan 14, 2021 · 0 comments
Closed

example1 #81009

tariqjamil-bwp opened this issue Jan 14, 2021 · 0 comments

Comments

@tariqjamil-bwp
Copy link

fn main() {
    let b1 = Book {
        id:1001,
        name:"rust in action",
    };
    
    b1.print();
}

struct Book {
    id:u32,
    name:&'static str,
}

trait Printable {
    fn print(&self);
}

impl Printable for Book{
    fn print(&self){
        println!("Printing Book with id:{} and name:{}", self.id, self.name);
    }
}

(Playground)

Output:

Printing Book with id:1001 and name:rust in action

Errors:

   Compiling playground v0.0.1 (/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 0.75s
     Running `target/debug/playground`

@rust-lang rust-lang locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants