Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
ismoilovdevml committed Sep 27, 2023
1 parent 6a96f88 commit 169eaaa
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
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"

Expand Down
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"

Expand Down
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]
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);
}
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"

Expand Down
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]
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);
}

0 comments on commit 169eaaa

Please sign in to comment.