mirror of https://github.com/rust-lang/rustlings
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
447 B
Rust
21 lines
447 B
Rust
2 years ago
|
// lifetimes3.rs
|
||
|
//
|
||
|
// Lifetimes are also needed when structs hold references.
|
||
|
//
|
||
|
// Execute `rustlings hint lifetimes3` or use the `hint` watch subcommand for a hint.
|
||
|
|
||
|
// I AM NOT DONE
|
||
|
|
||
|
struct Book {
|
||
|
author: &str,
|
||
|
title: &str,
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let name = String::from("Jill Smith");
|
||
|
let title = String::from("Fish Flying");
|
||
|
let book = Book { author: &name, title: &title };
|
||
|
|
||
|
println!("{} by {}", book.title, book.author);
|
||
|
}
|