mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-12 13:49:19 +00:00
27 lines
497 B
Rust
27 lines
497 B
Rust
// lifetimes4.rs
|
|
//
|
|
// So that the compiler can check lifetimes of supplied attributes
|
|
//
|
|
// Make me compile
|
|
//
|
|
// Execute the command `rustlings hint lifetimes4` if you need
|
|
// hints.
|
|
|
|
// I AM NOT DONE
|
|
|
|
#[derive(Debug)]
|
|
struct Book<'a> {
|
|
author: &'a str,
|
|
title: &'a str,
|
|
}
|
|
|
|
fn main() {
|
|
let name = String::from("Jill Smith");
|
|
let book;
|
|
{
|
|
let title = String::from("Fish Flying");
|
|
book = Book { author: &name, title: &title };
|
|
}
|
|
|
|
println!("{:?}", book);
|
|
} |