File tree 6 files changed +38
-0
lines changed
iterators_closures/tshirt_giveaway/src
6 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ fn main() {
55
55
let list = vec ! [ 1 , 2 , 3 ] ;
56
56
println ! ( "Before defining closure: {:?}" , list) ;
57
57
58
+
59
+ // The new thread may outlive the main thread, so we need to use move
60
+ // to transfer ownership of the list to the new thread
58
61
thread:: spawn ( move || println ! ( "From thread: {:?}" , list) )
59
62
. join ( )
60
63
. unwrap ( ) ;
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " modules_exercise"
3
+ version = " 0.1.0"
4
+ edition = " 2021"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+
8
+ [dependencies ]
Original file line number Diff line number Diff line change
1
+ pub mod hash {
2
+ pub struct Hash < T > {
3
+ pub hash : String ,
4
+ pub content : T ,
5
+ }
6
+ }
Original file line number Diff line number Diff line change
1
+ mod hasher{
2
+ use crate :: hash:: hash:: Hash ;
3
+
4
+ pub fn hash < T > ( data : T ) -> Hash < T > {
5
+ return Hash {
6
+ hash : String :: from ( "Placeholder" ) ,
7
+ content : data,
8
+ }
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ pub mod hasher;
2
+ pub mod hash;
3
+ pub mod storage;
Original file line number Diff line number Diff line change
1
+ pub mod storage {
2
+ use crate :: hash:: hash:: Hash ;
3
+
4
+ pub trait Storage {
5
+ fn get ( ) -> Hash < String > ;
6
+ fn put ( ) -> bool ;
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments