-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
struct User { | ||
active: bool, | ||
username: String, | ||
email: String, | ||
sign_in_count: u64, | ||
active: bool, | ||
} | ||
|
||
// ANCHOR: here | ||
fn main() { | ||
// ANCHOR: here | ||
let user1 = User { | ||
email: String::from("[email protected]"), | ||
username: String::from("someusername123"), | ||
active: true, | ||
username: String::from("someusername123"), | ||
email: String::from("[email protected]"), | ||
sign_in_count: 1, | ||
}; | ||
// ANCHOR_END: here | ||
} | ||
// ANCHOR_END: here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
struct User { | ||
active: bool, | ||
username: String, | ||
email: String, | ||
sign_in_count: u64, | ||
active: bool, | ||
} | ||
|
||
// ANCHOR: here | ||
fn main() { | ||
// ANCHOR: here | ||
let mut user1 = User { | ||
email: String::from("[email protected]"), | ||
username: String::from("someusername123"), | ||
active: true, | ||
username: String::from("someusername123"), | ||
email: String::from("[email protected]"), | ||
sign_in_count: 1, | ||
}; | ||
|
||
user1.email = String::from("[email protected]"); | ||
// ANCHOR_END: here | ||
} | ||
// ANCHOR_END: here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
struct User { | ||
active: bool, | ||
username: String, | ||
email: String, | ||
sign_in_count: u64, | ||
active: bool, | ||
} | ||
|
||
// ANCHOR: here | ||
fn main() { | ||
// --snip-- | ||
// ANCHOR_END: here | ||
|
||
let user1 = User { | ||
email: String::from("[email protected]"), | ||
username: String::from("someusername123"), | ||
active: true, | ||
sign_in_count: 1, | ||
}; | ||
|
||
// ANCHOR: here | ||
|
||
let user2 = User { | ||
email: String::from("[email protected]"), | ||
username: String::from("anotherusername567"), | ||
active: user1.active, | ||
username: user1.username, | ||
email: String::from("[email protected]"), | ||
sign_in_count: user1.sign_in_count, | ||
}; | ||
// ANCHOR_END: here | ||
} | ||
// ANCHOR_END: here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
struct User { | ||
active: bool, | ||
username: String, | ||
email: String, | ||
sign_in_count: u64, | ||
active: bool, | ||
} | ||
|
||
// ANCHOR: here | ||
fn main() { | ||
// --snip-- | ||
// ANCHOR_END: here | ||
|
||
let user1 = User { | ||
email: String::from("[email protected]"), | ||
username: String::from("someusername123"), | ||
active: true, | ||
sign_in_count: 1, | ||
}; | ||
|
||
// ANCHOR: here | ||
|
||
let user2 = User { | ||
email: String::from("[email protected]"), | ||
username: String::from("anotherusername567"), | ||
..user1 | ||
}; | ||
// ANCHOR_END: here | ||
} | ||
// ANCHOR_END: here |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
name = "rectangles" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
$ cargo run | ||
Compiling structs v0.1.0 (file:///projects/structs) | ||
Compiling rectangles v0.1.0 (file:///projects/rectangles) | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.42s | ||
Running `target/debug/structs` | ||
Running `target/debug/rectangles` | ||
The area of the rectangle is 1500 square pixels. | ||
(長方形の面積は、1500平方ピクセルです) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
name = "rectangles" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
name = "rectangles" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
name = "rectangles" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
$ cargo run | ||
Compiling structs v0.1.0 (file:///projects/structs) | ||
Compiling rectangles v0.1.0 (file:///projects/rectangles) | ||
error[E0277]: `Rectangle` doesn't implement `std::fmt::Display` | ||
(エラー: `Rectangle`は`std::fmt::Display`を実装していません) | ||
--> src/main.rs:12:29 | ||
| | ||
12 | println!("rect1 is {}", rect1); | ||
| ^^^^^ `Rectangle` cannot be formatted with the default formatter | ||
| | ||
= help: the trait `std::fmt::Display` is not implemented for `Rectangle` | ||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead | ||
= note: required by `std::fmt::Display::fmt` | ||
|
||
error: aborting due to previous error | ||
(ヘルプ: `std::fmt::Display`は`Rectangle`に対して実装されていません) | ||
(注釈: フォーマット文字列では代わりに`{:?}`(またはpretty-printするためには{:#?})が使用できるかもしれません) | ||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
For more information about this error, try `rustc --explain E0277`. | ||
error: could not compile `structs`. | ||
|
||
To learn more, run the command again with --verbose. | ||
error: could not compile `rectangles` (bin "rectangles") due to 1 previous error |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ fn main() { | |
height: 50, | ||
}; | ||
|
||
// rect1は{}です | ||
println!("rect1 is {}", rect1); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
name = "rectangles" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
$ cargo run | ||
Compiling structs v0.1.0 (file:///projects/structs) | ||
Compiling rectangles v0.1.0 (file:///projects/rectangles) | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.48s | ||
Running `target/debug/structs` | ||
Running `target/debug/rectangles` | ||
rect1 is Rectangle { width: 30, height: 50 } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[package] | ||
name = "structs" | ||
name = "rectangles" | ||
version = "0.1.0" | ||
authors = ["Your Name <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] |