-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a96f88
commit 169eaaa
Showing
7 changed files
with
22 additions
and
22 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
rustbook-uz/listings/ch13-functional-features/listing-13-03/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "closure-example" | ||
name = "namuna_closure" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
rustbook-uz/listings/ch13-functional-features/listing-13-04/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "closure-example" | ||
name = "namuna_closure" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
12 changes: 6 additions & 6 deletions
12
rustbook-uz/listings/ch13-functional-features/listing-13-04/output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
$ cargo run | ||
Compiling closure-example v0.1.0 (file:///projects/closure-example) | ||
Compiling namuna_closure v0.1.0 (file:///projects/namuna_closure) | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.43s | ||
Running `target/debug/closure-example` | ||
Before defining closure: [1, 2, 3] | ||
Before calling closure: [1, 2, 3] | ||
From closure: [1, 2, 3] | ||
After calling closure: [1, 2, 3] | ||
Running `target/debug/namuna_closure` | ||
Closureni belgilashdan oldin: [1, 2, 3] | ||
Closureni chaqirishdan oldin: [1, 2, 3] | ||
Closuredan: [1, 2, 3] | ||
Chaqirilgandan keyin closure: [1, 2, 3] |
10 changes: 5 additions & 5 deletions
10
rustbook-uz/listings/ch13-functional-features/listing-13-04/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
fn main() { | ||
let list = vec![1, 2, 3]; | ||
println!("Before defining closure: {:?}", list); | ||
println!("Closureni belgilashdan oldin: {:?}", list); | ||
|
||
let only_borrows = || println!("From closure: {:?}", list); | ||
let faqat_borrow = || println!("Closuredan: {:?}", list); | ||
|
||
println!("Before calling closure: {:?}", list); | ||
only_borrows(); | ||
println!("After calling closure: {:?}", list); | ||
println!("Closureni chaqirishdan oldin: {:?}", list); | ||
faqat_borrow(); | ||
println!("Chaqirilgandan keyin closure: {:?}", list); | ||
} |
2 changes: 1 addition & 1 deletion
2
rustbook-uz/listings/ch13-functional-features/listing-13-05/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "closure-example" | ||
name = "namuna_closure" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
8 changes: 4 additions & 4 deletions
8
rustbook-uz/listings/ch13-functional-features/listing-13-05/output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
$ cargo run | ||
Compiling closure-example v0.1.0 (file:///projects/closure-example) | ||
Compiling namuna_closure v0.1.0 (file:///projects/namuna_closure) | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.43s | ||
Running `target/debug/closure-example` | ||
Before defining closure: [1, 2, 3] | ||
After calling closure: [1, 2, 3, 7] | ||
Running `target/debug/namuna_closure` | ||
Closureni aniqlashdan oldin: [1, 2, 3] | ||
Chaqirilgandan keyin closure: [1, 2, 3, 7] |
8 changes: 4 additions & 4 deletions
8
rustbook-uz/listings/ch13-functional-features/listing-13-05/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
fn main() { | ||
let mut list = vec![1, 2, 3]; | ||
println!("Before defining closure: {:?}", list); | ||
println!("Closureni aniqlashdan oldin: {:?}", list); | ||
|
||
let mut borrows_mutably = || list.push(7); | ||
let mut ozgaruvchan_borrow = || list.push(7); | ||
|
||
borrows_mutably(); | ||
println!("After calling closure: {:?}", list); | ||
ozgaruvchan_borrow(); | ||
println!("Chaqirilgandan keyin closure: {:?}", list); | ||
} |