Skip to content

Commit 1dd4383

Browse files
committed
struct example
1 parent 7c046fe commit 1dd4383

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+94
-2
lines changed

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/learning-rust.iml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust-by-example/common/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn first_word(s: &String) -> usize {
180180

181181
s.len()
182182
}
183-
183+
// 遇到空格 返回空格之前的单词
184184
fn first_word_good(s: &str) -> &str {
185185
let bytes = s.as_bytes();
186186

@@ -190,7 +190,7 @@ fn first_word_good(s: &str) -> &str {
190190
}
191191
}
192192

193-
&s[..]
193+
&s[..]// 返回的竟然是空格之前的单词
194194
}
195195

196196
fn change_mut(s: &mut String) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "struct_example"
3+
version = "0.1.0"
4+
authors = ["pathbox <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
fn main() {
2+
3+
let mut user = User {
4+
email: String::from("[email protected]"),
5+
username: String::from("anotherusername567"),
6+
active: true,
7+
sign_in_count: 1,
8+
};
9+
10+
struct Color(i32, i32, i32);
11+
struct Point(i32, i32, i32);
12+
13+
let black = Color(0, 0, 0);
14+
let origin = Point(0, 0, 0);
15+
16+
println!("email: {}", user.email);
17+
}
18+
19+
struct User {
20+
username: String,
21+
email: String,
22+
sign_in_count: u64,
23+
active: bool,
24+
}
25+
26+
27+
fn build_user(email: String, username: String) -> User {
28+
User {
29+
email: email,
30+
username: username,
31+
active: true,
32+
sign_in_count: 1,
33+
}
34+
35+
// User {
36+
// email,
37+
// username,
38+
// active: true,
39+
// sign_in_count: 1,
40+
// }
41+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"rustc_fingerprint":15207764190234867346,"outputs":{"4476964694761187371":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/cary/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""],"1164083562126845933":["rustc 1.37.0 (eae3437df 2019-08-13)\nbinary: rustc\ncommit-hash: eae3437dfe991621e8afdc82734f4a172d7ddf9b\ncommit-date: 2019-08-13\nhost: x86_64-unknown-linux-gnu\nrelease: 1.37.0\nLLVM version: 8.0\n",""],"2196823701345282402":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/cary/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""]},"successes":{}}

rust-by-example/struct_example/target/debug/.cargo-lock

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1d48db0211560755
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"rustc":15611408172799703797,"features":"[]","target":5438935040497977383,"profile":14996655781355331481,"path":1036222786711178230,"deps":[],"local":[{"CheckDepInfo":{"dep_info":".fingerprint/struct_example-14093e3c129100cc/dep-bin-struct_example-14093e3c129100cc"}}],"rustflags":[],"metadata":13891358230532845808}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file has an mtime of when this was started.
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/mnt/e/CaryCode/learning-rust/rust-by-example/struct_example/target/debug/deps/struct_example-14093e3c129100cc: src/main.rs
2+
3+
/mnt/e/CaryCode/learning-rust/rust-by-example/struct_example/target/debug/deps/struct_example-14093e3c129100cc.d: src/main.rs
4+
5+
src/main.rs:

rust-by-example/struct_example/target/debug/incremental/struct_example-u4k1xyvmkq8h/s-fglpzaqruj-15g12c0.lock

Whitespace-only changes.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/mnt/e/CaryCode/learning-rust/rust-by-example/struct_example/target/debug/struct_example: /mnt/e/CaryCode/learning-rust/rust-by-example/struct_example/src/main.rs

0 commit comments

Comments
 (0)