├── .gitignore ├── lec07 ├── src │ ├── stuff │ │ ├── b.rs │ │ ├── c.rs │ │ ├── a.rs │ │ └── mod.rs │ ├── stuff2 │ │ ├── b.rs │ │ ├── c.rs │ │ └── a.rs │ ├── another_file.rs │ ├── stuff2.rs │ ├── lib.rs │ └── point.rs ├── diagram.jpg ├── diagram.ora ├── diagram.png ├── Cargo.lock └── Cargo.toml ├── lec04 ├── foo.txt ├── JavaErrors │ ├── foo.txt │ ├── .idea │ │ ├── vcs.xml │ │ ├── .gitignore │ │ ├── modules.xml │ │ └── misc.xml │ ├── JavaErrors.iml │ ├── .gitignore │ └── src │ │ └── Main.java ├── errors │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ │ └── main.rs ├── collections │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ │ └── main.rs └── errors.c ├── lec17 ├── exam_q7_24T3 │ └── q7.txt ├── exam_q1_24T3 │ ├── q1_3.txt │ ├── q1 │ │ ├── Cargo.toml │ │ ├── Cargo.lock │ │ └── src │ │ │ └── main.rs │ ├── q1_1.txt │ ├── q1_2.txt │ └── q1_4.txt ├── exam_q4_24T3 │ ├── q4_1.txt │ ├── q4_2.txt │ ├── q4_3.txt │ ├── q4_1 │ │ ├── Cargo.toml │ │ ├── Cargo.lock │ │ └── src │ │ │ └── main.rs │ └── q4_3 │ │ ├── Cargo.toml │ │ ├── Cargo.lock │ │ └── src │ │ └── main.rs ├── exam_q6_24T3 │ ├── q6_1.txt │ ├── q6_2.txt │ └── unsafe_review │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ ├── main.rs │ │ └── lib.rs ├── exam_q3_24T3 │ ├── q3_1.txt │ ├── q3_2.txt │ └── q3_3.txt ├── exam_q2_24T3 │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ ├── main.rs │ │ └── lib.rs └── exam_q5_24T3 │ ├── Cargo.toml │ └── src │ ├── main_alt.rs │ ├── main.rs │ ├── main_alt2.rs │ ├── lib.rs │ └── main_alt3.rs ├── lec11 ├── yew-demo │ ├── .gitignore │ ├── src │ │ ├── main.rs │ │ └── app.rs │ ├── index.html │ ├── Cargo.toml │ ├── index.scss │ ├── LICENSE-MIT │ ├── README.md │ ├── LICENSE-APACHE │ └── Cargo.lock ├── sqlx-demo │ ├── .env │ ├── test.db │ ├── Cargo.toml │ ├── src │ │ └── main.rs │ └── Cargo.lock ├── rust │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ │ ├── sort.rs │ │ └── main.rs ├── create_program.sh ├── c │ ├── up_to.c │ ├── max.c │ └── sort.c └── program.sh ├── lec01 ├── hello_world │ ├── src │ │ └── main.rs │ ├── Cargo.toml │ └── Cargo.lock └── lines │ ├── my_image.bmp │ ├── Cargo.toml │ ├── Cargo.lock │ ├── src │ └── main.rs │ └── lines.c ├── lec05 ├── diagram.jpg ├── diagram.ora ├── diagram.png ├── Cargo.toml ├── src │ ├── main.rs │ ├── dangling.rs │ ├── pain.rs │ ├── shared.rs │ └── exclusive.rs ├── list.c └── Cargo.lock ├── lec06 ├── diagram.jpg ├── diagram.ora ├── diagram.png ├── Cargo.toml ├── Cargo.lock ├── foo.c └── src │ ├── dangling.rs │ ├── slice.rs │ ├── main.rs │ └── longest.rs ├── lec09 ├── .python_add.py.swp ├── traits │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ │ └── main.rs ├── polymorphism │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ │ └── main.rs ├── python_add.py └── notes.md ├── lec12 ├── Cargo.toml ├── lec12-extension-trait │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ │ └── main.rs ├── Cargo.lock └── src │ └── main.rs ├── lec15 ├── Cargo.toml ├── Cargo.lock ├── src │ └── main.rs └── foo.c ├── lec16 └── vec-insane │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ └── main.rs ├── lec03 ├── collections │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ │ └── main.rs └── playing_around │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ └── main.rs ├── lec14 ├── Cargo.toml ├── add.c ├── src │ └── main.rs ├── Cargo.lock └── thread_sum.c ├── lec02 ├── playing_around │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ │ └── main.rs └── optional │ ├── optional.py │ ├── optional.cpp │ ├── Option.java │ ├── optional.go │ ├── optional.c │ └── optional.rs └── lec13 ├── rust-race ├── Cargo.lock ├── Cargo.toml └── src │ ├── unsafe_race.rs │ ├── main.rs │ └── data_race.rs ├── data_race.py ├── data_race.go ├── fix_race.go ├── data_race.c ├── DataRace.java ├── FixRace.java └── fix_race.c /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /lec07/src/stuff/b.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lec07/src/stuff/c.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lec07/src/stuff2/b.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lec07/src/stuff2/c.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lec04/foo.txt: -------------------------------------------------------------------------------- 1 | hello 2 | 3 | -------------------------------------------------------------------------------- /lec17/exam_q7_24T3/q7.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lec04/JavaErrors/foo.txt: -------------------------------------------------------------------------------- 1 | here is a line -------------------------------------------------------------------------------- /lec07/src/stuff/a.rs: -------------------------------------------------------------------------------- 1 | pub struct A; 2 | -------------------------------------------------------------------------------- /lec07/src/another_file.rs: -------------------------------------------------------------------------------- 1 | pub struct Hello; 2 | -------------------------------------------------------------------------------- /lec07/src/stuff2/a.rs: -------------------------------------------------------------------------------- 1 | pub struct Stuff2; 2 | -------------------------------------------------------------------------------- /lec17/exam_q1_24T3/q1_3.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | 3 | 2. 4 | -------------------------------------------------------------------------------- /lec17/exam_q4_24T3/q4_1.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | 3 | 2. 4 | -------------------------------------------------------------------------------- /lec17/exam_q6_24T3/q6_1.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | 3 | 2. 4 | -------------------------------------------------------------------------------- /lec11/yew-demo/.gitignore: -------------------------------------------------------------------------------- 1 | /dist/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /lec07/src/stuff2.rs: -------------------------------------------------------------------------------- 1 | pub mod a; 2 | mod b; 3 | mod c; 4 | -------------------------------------------------------------------------------- /lec11/sqlx-demo/.env: -------------------------------------------------------------------------------- 1 | DATABASE_URL="sqlite://test.db" 2 | -------------------------------------------------------------------------------- /lec17/exam_q3_24T3/q3_1.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | 3 | 2. 4 | 5 | 3. 6 | -------------------------------------------------------------------------------- /lec17/exam_q3_24T3/q3_2.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | 3 | 2. 4 | 5 | 3. 6 | -------------------------------------------------------------------------------- /lec17/exam_q4_24T3/q4_2.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | 3 | 2. 4 | 5 | 3. 6 | -------------------------------------------------------------------------------- /lec17/exam_q4_24T3/q4_3.txt: -------------------------------------------------------------------------------- 1 | macro_rules! map { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /lec17/exam_q6_24T3/q6_2.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | 3 | 2. 4 | 5 | 3. 6 | 7 | 4. 8 | -------------------------------------------------------------------------------- /lec01/hello_world/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, there world!"); 3 | } 4 | -------------------------------------------------------------------------------- /lec05/diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec05/diagram.jpg -------------------------------------------------------------------------------- /lec05/diagram.ora: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec05/diagram.ora -------------------------------------------------------------------------------- /lec05/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec05/diagram.png -------------------------------------------------------------------------------- /lec06/diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec06/diagram.jpg -------------------------------------------------------------------------------- /lec06/diagram.ora: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec06/diagram.ora -------------------------------------------------------------------------------- /lec06/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec06/diagram.png -------------------------------------------------------------------------------- /lec07/diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec07/diagram.jpg -------------------------------------------------------------------------------- /lec07/diagram.ora: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec07/diagram.ora -------------------------------------------------------------------------------- /lec07/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec07/diagram.png -------------------------------------------------------------------------------- /lec11/sqlx-demo/test.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec11/sqlx-demo/test.db -------------------------------------------------------------------------------- /lec01/lines/my_image.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec01/lines/my_image.bmp -------------------------------------------------------------------------------- /lec09/.python_add.py.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/COMP6991UNSW/lec-materials/HEAD/lec09/.python_add.py.swp -------------------------------------------------------------------------------- /lec06/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lec06" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec07/src/stuff/mod.rs: -------------------------------------------------------------------------------- 1 | pub struct Stuff; 2 | 3 | pub mod a; 4 | 5 | pub use a::A; 6 | 7 | mod b; 8 | mod c; 9 | -------------------------------------------------------------------------------- /lec12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lec12" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec15/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lec15" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec04/errors/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "errors" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec09/traits/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "traits" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec16/vec-insane/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "vec-insane" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec17/exam_q1_24T3/q1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "q1" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec17/exam_q4_24T3/q4_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "q4_1" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec17/exam_q4_24T3/q4_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "q4_3" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec01/hello_world/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello_world" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec03/collections/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "collections" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec05/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lec05" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | bmp = "0.5.0" 8 | -------------------------------------------------------------------------------- /lec09/polymorphism/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "polymorphism" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec11/yew-demo/src/main.rs: -------------------------------------------------------------------------------- 1 | mod app; 2 | 3 | use app::App; 4 | 5 | fn main() { 6 | yew::Renderer::::new().render(); 7 | } 8 | -------------------------------------------------------------------------------- /lec14/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lec14" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | rayon = "1.10.0" 8 | -------------------------------------------------------------------------------- /lec01/lines/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lines" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | bmp = "0.5.0" 8 | -------------------------------------------------------------------------------- /lec02/playing_around/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "playing_around" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec03/playing_around/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "playing_around" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec11/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | paste = "1.0.15" 8 | -------------------------------------------------------------------------------- /lec09/python_add.py: -------------------------------------------------------------------------------- 1 | class Point: 2 | x: int 3 | y: int 4 | 5 | def __add__(self, rhs): 6 | Point(self.x + rhs.x, self.y + rhs.y) 7 | -------------------------------------------------------------------------------- /lec12/lec12-extension-trait/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lec12-extension-trait" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /lec04/collections/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "collections" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | itertools = "0.14.0" 8 | -------------------------------------------------------------------------------- /lec11/create_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo '#!/bin/sh' >> program.sh 4 | for i in $(seq 100); do 5 | echo "echo $i" >> program.sh 6 | done 7 | 8 | chmod +x program.sh 9 | -------------------------------------------------------------------------------- /lec06/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "lec06" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec07/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "lec07" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec12/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "lec12" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec15/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "lec15" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec06/foo.c: -------------------------------------------------------------------------------- 1 | bool have_i_done_the_thing = false; 2 | 3 | void foo(void) { 4 | if (!have_i_done_the_thing) { 5 | do_the_thing(); 6 | 7 | have_i_done_the_thing = true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lec14/add.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | double sum = 0.0; 5 | for (double i = 0; i < 10000000000; i++) { 6 | sum += i; 7 | } 8 | printf("%lf\n", sum); 9 | } 10 | -------------------------------------------------------------------------------- /lec04/errors/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "errors" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec09/traits/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "traits" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec17/exam_q1_24T3/q1_1.txt: -------------------------------------------------------------------------------- 1 | Option 2 | The Err(()) does not communicate 3 | any additional information than None 4 | from Option, so this is perfectly 5 | suitable or even an improvement! 6 | -------------------------------------------------------------------------------- /lec13/rust-race/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "rust-race" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec17/exam_q1_24T3/q1/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "q1" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec01/hello_world/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "hello_world" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec03/collections/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "collections" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec09/polymorphism/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "polymorphism" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec16/vec-insane/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "vec-insane" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec17/exam_q2_24T3/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "exam_q2_24T3" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec17/exam_q4_24T3/q4_1/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "q4_1" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec17/exam_q4_24T3/q4_3/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "q4_3" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec02/playing_around/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "playing_around" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec03/playing_around/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "playing_around" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec05/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | mod pain; 4 | mod shared; 5 | mod exclusive; 6 | mod dangling; 7 | 8 | fn main() { 9 | let mut my_string = String::from("hello"); 10 | dbg!(my_string); 11 | } 12 | -------------------------------------------------------------------------------- /lec17/exam_q6_24T3/unsafe_review/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "unsafe_review" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec12/lec12-extension-trait/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "lec12-extension-trait" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /lec04/JavaErrors/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lec13/rust-race/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-race" 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] 9 | -------------------------------------------------------------------------------- /lec04/JavaErrors/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /lec11/yew-demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Trunk Template 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /lec17/exam_q6_24T3/unsafe_review/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unsafe_review" 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] 9 | -------------------------------------------------------------------------------- /lec05/src/dangling.rs: -------------------------------------------------------------------------------- 1 | struct LinkedList { 2 | data: i32, 3 | next: Option>, 4 | } 5 | 6 | fn create_linked_list(data: i32) -> Box { 7 | let list = LinkedList { 8 | data, 9 | next: None, 10 | }; 11 | 12 | Box::new(list) 13 | } 14 | -------------------------------------------------------------------------------- /lec15/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut v = vec![1, 2, 3]; 3 | // Safety: 4 | // new_len must be less than or equal to capacity(). 5 | // - ... 6 | // 7 | // The elements at old_len..new_len must be initialized. 8 | // - ... 9 | unsafe { v.set_len(7); } 10 | } 11 | -------------------------------------------------------------------------------- /lec04/JavaErrors/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lec04/JavaErrors/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lec04/errors/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | 3 | fn main() { 4 | let file = match File::open("foo.txt") { 5 | Ok(file) => file, 6 | Err(err) => { 7 | println!("ERROR: {err:?}"); 8 | return; 9 | } 10 | }; 11 | 12 | let file = File::open("foo.txt"); 13 | } 14 | -------------------------------------------------------------------------------- /lec07/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lec07" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [lib] 7 | name = "my_library" 8 | path = "src/lib.rs" 9 | 10 | # [[bin]] 11 | # name = "my_binary" 12 | # path = "src/main.rs" 13 | 14 | # [[bin]] 15 | # name = "my_binary_two" 16 | # path = "src/main_two.rs" 17 | 18 | [dependencies] 19 | -------------------------------------------------------------------------------- /lec17/exam_q1_24T3/q1_2.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | Ownership. 3 | Ownership causes values to be moved, 4 | at which point the original cannot be used anymore. 5 | > Assigning string1 causes the first move, 6 | > and assigning string2 tries to move my_string a 7 | > second time, which causes the error. 8 | 2. 9 | .clone() 10 | .as_ref() 11 | .as_str() 12 | .deref() 13 | -------------------------------------------------------------------------------- /lec04/errors.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void do_something_with_file(FILE *file); 4 | 5 | int main(void) { 6 | FILE *file = fopen("foo.txt", "r"); 7 | 8 | char line[1024]; 9 | fgets(line, sizeof line, file); 10 | printf("%s", line); 11 | 12 | do_something_with_file(file); 13 | } 14 | 15 | void do_something_with_file(FILE *file) { 16 | // TODO 17 | } 18 | -------------------------------------------------------------------------------- /lec11/sqlx-demo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sqlx-demo" 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] 9 | sqlx = { version = "0.6.3", features = ["runtime-tokio-native-tls", "sqlite"] } 10 | tokio = { version = "1.26.0", features = ["full"] } 11 | -------------------------------------------------------------------------------- /lec17/exam_q6_24T3/unsafe_review/src/main.rs: -------------------------------------------------------------------------------- 1 | use unsafe_review::Lazy; 2 | 3 | fn main() { 4 | let lazy = Lazy::new(|| { 5 | println!("initializing..."); 6 | 42 7 | }); 8 | 9 | // run this twice 10 | for _ in 0..2 { 11 | println!("reading from lazy..."); 12 | let value = *lazy; 13 | println!("got {value}"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lec05/list.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct node { 5 | int data; 6 | struct node *next; 7 | }; 8 | 9 | struct node *create_list(int first_data) { 10 | struct node head; 11 | head.data = first_data; 12 | head.next = NULL; 13 | return &head; 14 | } 15 | 16 | int main(void) { 17 | struct node *list = create_list(42); 18 | list->next = create_list(43); 19 | list->next->next = create_list(44); 20 | } 21 | -------------------------------------------------------------------------------- /lec11/c/up_to.c: -------------------------------------------------------------------------------- 1 | // Examples from: https://www.cs.yale.edu/homes/aspnes/pinewiki/C(2f)Macros.html 2 | 3 | #include 4 | #include 5 | 6 | #define UP_TO(type, i, n) for (type i = 0; i < n; i++) 7 | 8 | int main(void) { 9 | UP_TO(int, foo, 10) { 10 | printf("%d\n", foo); 11 | } 12 | 13 | // should make: 14 | // for (int foo = 0; foo < 10; foo++) { 15 | // printf("%d\n", foo); 16 | // } 17 | } 18 | -------------------------------------------------------------------------------- /lec11/rust/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "paste" 7 | version = "1.0.15" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" 10 | 11 | [[package]] 12 | name = "rust" 13 | version = "0.1.0" 14 | dependencies = [ 15 | "paste", 16 | ] 17 | -------------------------------------------------------------------------------- /lec11/yew-demo/src/app.rs: -------------------------------------------------------------------------------- 1 | use yew::prelude::*; 2 | 3 | #[function_component(App)] 4 | pub fn app() -> Html { 5 | let counter = use_state(|| 0); 6 | 7 | html! { 8 |
9 | 10 |

{ "Counter: " }{ *counter }

11 | 12 |
13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lec17/exam_q2_24T3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "exam_q2_24T3" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [[bin]] 9 | path = "src/main.rs" 10 | name = "exam_q2" 11 | 12 | [lib] 13 | path = "src/lib.rs" 14 | name = "exam_q2_lib" 15 | 16 | [dependencies] 17 | 18 | [features] 19 | find_str_bad_lifetimes = [] 20 | most_common_bad_lifetimes = [] 21 | -------------------------------------------------------------------------------- /lec04/JavaErrors/JavaErrors.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /lec04/JavaErrors/.gitignore: -------------------------------------------------------------------------------- 1 | ### IntelliJ IDEA ### 2 | out/ 3 | !**/src/main/**/out/ 4 | !**/src/test/**/out/ 5 | 6 | ### Eclipse ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | bin/ 15 | !**/src/main/**/bin/ 16 | !**/src/test/**/bin/ 17 | 18 | ### NetBeans ### 19 | /nbproject/private/ 20 | /nbbuild/ 21 | /dist/ 22 | /nbdist/ 23 | /.nb-gradle/ 24 | 25 | ### VS Code ### 26 | .vscode/ 27 | 28 | ### Mac OS ### 29 | .DS_Store -------------------------------------------------------------------------------- /lec17/exam_q1_24T3/q1_4.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | Option<&str> 3 | 2. 4 | Type inference 5 | 3. 6 | The way predicted_result is assigned through 7 | the result variable being mutated is non-idiomatic. 8 | Improvement: 9 | 10 | let predicted_result = match (zid, wam) { 11 | (_, wam) if wam >= 50 => Some("PS"), 12 | (5205060, _) => Some("FL"), 13 | _ => None, 14 | }; 15 | 16 | let predicted_result = if wam >= 50 { 17 | Some("PS") 18 | } else if zid == 5205060 { 19 | Some("FL") 20 | } else { 21 | None 22 | }; 23 | -------------------------------------------------------------------------------- /lec13/data_race.py: -------------------------------------------------------------------------------- 1 | import threading 2 | 3 | N_THREADS = 50 4 | N_INCREMENTS = 100000 5 | 6 | my_number = 0 7 | 8 | def thread(): 9 | global my_number 10 | for _ in range(N_INCREMENTS): 11 | my_number += 1 12 | 13 | threads = [] 14 | 15 | for _ in range(N_THREADS): 16 | my_thread = threading.Thread(target=thread) 17 | my_thread.start() 18 | threads.append(my_thread) 19 | 20 | for thread in threads: 21 | thread.join() 22 | 23 | print(f'Final total: {my_number} (expected {N_THREADS * N_INCREMENTS})') 24 | -------------------------------------------------------------------------------- /lec11/c/max.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define ADD5(x) ((x) + 5) 4 | #define MUL7(x) ((x) * 7) 5 | 6 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 7 | 8 | int add5(int x) { return x + 5; } 9 | 10 | int max(int a, int b) { 11 | return a > b ? a : b; 12 | } 13 | 14 | // T dbg(T value) { 15 | // printf("{value:?}"); 16 | // return value; 17 | // } 18 | 19 | int dbg(int value) { 20 | printf("DBG: %d\n", value); 21 | return value; 22 | } 23 | 24 | int main(void) { 25 | int x = MAX(dbg(5 + 5), dbg(21 * 2)); 26 | printf("%d\n", x); 27 | } 28 | -------------------------------------------------------------------------------- /lec11/yew-demo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "yew-demo" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "Template for starting a Yew project using Trunk" 6 | readme = "README.md" 7 | repository = "https://github.com/yewstack/yew-trunk-minimal-template" 8 | license = "MIT OR Apache-2.0" 9 | keywords = ["yew", "trunk"] 10 | categories = ["gui", "wasm", "web-programming"] 11 | 12 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 13 | [dependencies] 14 | yew = { version="0.21", features=["csr"] } -------------------------------------------------------------------------------- /lec15/foo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void do_stuff(void) { 4 | // spawn a new thread 5 | // wait for that thread to kick off 6 | // look at main's memory (in a loop) 7 | // look for the value "17" anywhere 8 | // change that to "25" 9 | } 10 | 11 | int main(void) { 12 | char *first = strtok("abc:def:ghi", ":"); // "abc" 13 | char *second = strtok(NULL, ":"); // "def" 14 | char *third = strtok(NULL, ":"); // "ghi" 15 | char *fourth = strtok(NULL, ":"); // NULL 16 | 17 | do_stuff(); 18 | 19 | int x = 25; 20 | int y = 25; 21 | puts("42"); 22 | } 23 | -------------------------------------------------------------------------------- /lec11/yew-demo/index.scss: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | height: 100%; 4 | margin: 0; 5 | } 6 | 7 | body { 8 | align-items: center; 9 | display: flex; 10 | justify-content: center; 11 | 12 | background: linear-gradient(to bottom right, #444444, #009a5b); 13 | font-size: 1.5rem; 14 | } 15 | 16 | main { 17 | color: #fff6d5; 18 | font-family: sans-serif; 19 | text-align: center; 20 | } 21 | 22 | .logo { 23 | height: 20em; 24 | } 25 | 26 | h1 { 27 | display: block; 28 | margin-top: -1em; 29 | } 30 | 31 | button { 32 | font-size: 2em; 33 | padding: 0.5em; 34 | } 35 | -------------------------------------------------------------------------------- /lec11/sqlx-demo/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error; 2 | use std::str::FromStr; 3 | 4 | use sqlx::ConnectOptions; 5 | use sqlx::sqlite::SqliteConnectOptions; 6 | 7 | #[tokio::main] 8 | async fn main() -> Result<(), Box> { 9 | let mut conn = SqliteConnectOptions::from_str("sqlite://test.db")? 10 | .connect() 11 | .await?; 12 | 13 | let account = sqlx::query!("select first_name, last_name, email, phone from contacts") 14 | .fetch_one(&mut conn) 15 | .await?; 16 | 17 | println!("{}", account.email); 18 | 19 | Ok(()) 20 | } 21 | -------------------------------------------------------------------------------- /lec02/optional/optional.py: -------------------------------------------------------------------------------- 1 | # run with: `python3 optional.py` 2 | 3 | def create(b): 4 | if b: 5 | return "Hello there" 6 | else: 7 | return None 8 | 9 | def main(): 10 | # Method 1 11 | create_true = create(True) 12 | if create_true is not None: 13 | print("create(True) returned " + create_true) 14 | 15 | # Method 2 16 | create_false = create(False) 17 | print( 18 | "create(False) returned " 19 | + create_false if create_false is not None else "" 20 | ) 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /lec17/exam_q5_24T3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "exam_q5" 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 | [[bin]] 9 | path = "src/main.rs" 10 | name = "exam_q5" 11 | 12 | [[bin]] 13 | path = "src/main_alt.rs" 14 | name = "exam_q5_alt" 15 | 16 | [[bin]] 17 | path = "src/main_alt2.rs" 18 | name = "exam_q5_alt2" 19 | 20 | [[bin]] 21 | path = "src/main_alt3.rs" 22 | name = "exam_q5_alt3" 23 | 24 | [lib] 25 | path = "src/lib.rs" 26 | name = "exam_q5_lib" 27 | 28 | [dependencies] 29 | -------------------------------------------------------------------------------- /lec13/data_race.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | const NThreads = 50 9 | const NIncrements = 100000 10 | 11 | func main() { 12 | var wg sync.WaitGroup 13 | wg.Add(NThreads) 14 | 15 | my_number := 0 16 | 17 | for i := 0; i < NThreads; i++ { 18 | go func() { 19 | for n := 0; n < NIncrements; n++ { 20 | my_number++ 21 | } 22 | wg.Done() 23 | }() 24 | } 25 | 26 | wg.Wait() 27 | 28 | fmt.Printf("Final total: %d (expected %d)\n", my_number, NThreads*NIncrements) 29 | } 30 | -------------------------------------------------------------------------------- /lec04/JavaErrors/src/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.BufferedReader; 2 | import java.io.File; 3 | import java.io.FileReader; 4 | 5 | public class Main { 6 | void main() { 7 | var fileName = "foo.txt"; 8 | var line = readLineFromFile(fileName); 9 | 10 | System.out.println(line); 11 | } 12 | 13 | String readLineFromFile(String fileName) { 14 | var file = new File(fileName); 15 | var reader = new BufferedReader(new FileReader(file)); 16 | return reader.readLine(); 17 | } 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | public static void main(String[] args) { 29 | new Main().main(); 30 | } 31 | } -------------------------------------------------------------------------------- /lec05/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "bmp" 7 | version = "0.5.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "69985ff4f58085ac696454692d0b646a66ad1f9cc9be294c91dc51bb5df511ae" 10 | dependencies = [ 11 | "byteorder", 12 | ] 13 | 14 | [[package]] 15 | name = "byteorder" 16 | version = "1.5.0" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 19 | 20 | [[package]] 21 | name = "lec05" 22 | version = "0.1.0" 23 | dependencies = [ 24 | "bmp", 25 | ] 26 | -------------------------------------------------------------------------------- /lec01/lines/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "bmp" 7 | version = "0.5.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "69985ff4f58085ac696454692d0b646a66ad1f9cc9be294c91dc51bb5df511ae" 10 | dependencies = [ 11 | "byteorder", 12 | ] 13 | 14 | [[package]] 15 | name = "byteorder" 16 | version = "1.5.0" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 19 | 20 | [[package]] 21 | name = "lines" 22 | version = "0.1.0" 23 | dependencies = [ 24 | "bmp", 25 | ] 26 | -------------------------------------------------------------------------------- /lec13/fix_race.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | const NThreads = 50 9 | const NIncrements = 100000 10 | 11 | func main() { 12 | var mutex sync.Mutex 13 | 14 | var wg sync.WaitGroup 15 | wg.Add(NThreads) 16 | 17 | my_number := 0 18 | 19 | for i := 0; i < NThreads; i++ { 20 | go func() { 21 | for n := 0; n < NIncrements; n++ { 22 | mutex.Lock() 23 | my_number++ 24 | mutex.Unlock() 25 | } 26 | wg.Done() 27 | }() 28 | } 29 | 30 | wg.Wait() 31 | 32 | fmt.Printf("Final total: %d (expected %d)\n", my_number, NThreads*NIncrements) 33 | } 34 | 35 | -------------------------------------------------------------------------------- /lec04/collections/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "collections" 7 | version = "0.1.0" 8 | dependencies = [ 9 | "itertools", 10 | ] 11 | 12 | [[package]] 13 | name = "either" 14 | version = "1.14.0" 15 | source = "registry+https://github.com/rust-lang/crates.io-index" 16 | checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d" 17 | 18 | [[package]] 19 | name = "itertools" 20 | version = "0.14.0" 21 | source = "registry+https://github.com/rust-lang/crates.io-index" 22 | checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" 23 | dependencies = [ 24 | "either", 25 | ] 26 | -------------------------------------------------------------------------------- /lec13/rust-race/src/unsafe_race.rs: -------------------------------------------------------------------------------- 1 | const N_THREADS: usize = 50; 2 | const N_INCREMENTS: usize = 100000; 3 | 4 | use std::{array, thread::JoinHandle}; 5 | 6 | use super::*; 7 | 8 | static mut MY_NUMBER: u64 = 0; 9 | 10 | fn thread() { 11 | for _ in 0..N_INCREMENTS { 12 | unsafe { MY_NUMBER += 1 }; 13 | } 14 | } 15 | 16 | pub fn main() { 17 | let mut threads = [const { None }; N_THREADS]; 18 | 19 | for i in 0..N_THREADS { 20 | threads[i] = Some(std::thread::spawn(thread)); 21 | } 22 | for i in 0..N_THREADS { 23 | threads[i].take().unwrap().join(); 24 | } 25 | 26 | println!("(Unsafe) Final total: {} (expected {})\n", unsafe { MY_NUMBER }, N_THREADS * N_INCREMENTS); 27 | } 28 | -------------------------------------------------------------------------------- /lec02/optional/optional.cpp: -------------------------------------------------------------------------------- 1 | // Build with: clang++ -std=c++17 optional.cpp -o optional_cpp 2 | 3 | #include 4 | #include 5 | 6 | std::optional create(bool b) { 7 | if (b) { 8 | return std::optional{"Hello there!"}; 9 | } else { 10 | return std::nullopt; 11 | } 12 | } 13 | 14 | int main() { 15 | // method one 16 | auto create_true = create(true); 17 | if (create_true) { 18 | std::cout << "create(true) returned " 19 | << *create_true 20 | << '\n'; 21 | } 22 | 23 | // method two 24 | std::cout << "create(false) returned " 25 | << create(false).value_or("") 26 | << '\n'; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /lec13/data_race.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define N_THREADS 50 6 | #define N_INCREMENTS 100000 7 | 8 | int my_number = 0; 9 | 10 | void *thread(void *data) { 11 | for (int i = 0; i < N_INCREMENTS; i++) { 12 | my_number = my_number + 1; 13 | } 14 | 15 | return NULL; 16 | } 17 | 18 | int main(void) { 19 | pthread_t *thrs = malloc(sizeof(pthread_t) * N_THREADS); 20 | 21 | for (int i = 0; i < N_THREADS; i++) { 22 | pthread_create(&thrs[i], NULL, thread, NULL); 23 | } 24 | for (int i = 0; i < N_THREADS; i++) { 25 | pthread_join(thrs[i], NULL); 26 | } 27 | 28 | printf("Final total: %d (expected %d)\n", my_number, N_THREADS * N_INCREMENTS); 29 | } 30 | -------------------------------------------------------------------------------- /lec05/src/pain.rs: -------------------------------------------------------------------------------- 1 | use bmp::Image; 2 | 3 | pub fn main() { 4 | let mut image = Image::new(256, 256); 5 | draw_line(&mut image, 20, 20, 80, LineDirection::Horizontal); 6 | 7 | image.save("my_image.bmp").unwrap(); 8 | } 9 | 10 | enum LineDirection { 11 | Vertical, 12 | Horizontal, 13 | } 14 | 15 | fn draw_line(image: &mut Image, x: u32, y: u32, length: u32, direction: LineDirection) { 16 | for i in 0..length { 17 | let (cur_x, cur_y) = match direction { 18 | LineDirection::Horizontal => { 19 | (x + i, y) 20 | } 21 | LineDirection::Vertical => { 22 | (x, y + i) 23 | } 24 | }; 25 | 26 | image.set_pixel(cur_x, cur_y, bmp::consts::RED); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lec02/optional/Option.java: -------------------------------------------------------------------------------- 1 | // build with: javac Option.java 2 | // run with: java Option 3 | 4 | import java.util.Optional; 5 | 6 | class Option { 7 | static Optional create(boolean b) { 8 | if (b) { 9 | return Optional.of("Hello there!"); 10 | } else { 11 | return Optional.empty(); 12 | } 13 | } 14 | 15 | public static void main(String[] args) { 16 | Optional create_true = create(true); 17 | if (create_true.isPresent()) { 18 | System.out.println("create(true) returned " + create_true.get()); 19 | } 20 | 21 | System.out.println( 22 | "create(false) returned " 23 | + create(false).orElse("") 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lec17/exam_q1_24T3/q1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | fn main() { 3 | let wam = 50; 4 | let zid = 1234567; 5 | let predicted_result: Option<&str> = { 6 | let mut result = None; 7 | if zid == 5205060 { 8 | result = Some("FL"); 9 | } 10 | if wam >= 50 { 11 | result = Some("PS"); 12 | } 13 | result 14 | }; 15 | 16 | println!("{:?}", predicted_result); 17 | 18 | } 19 | } 20 | 21 | fn foo() -> Result { 22 | // Ok(String::from("hello")) 23 | Err(()) 24 | 25 | // todo!() 26 | } 27 | 28 | fn foo2() -> Option { 29 | // Some(String::from("hello")) 30 | None 31 | 32 | // todo!() 33 | } 34 | -------------------------------------------------------------------------------- /lec02/optional/optional.go: -------------------------------------------------------------------------------- 1 | // run with `go run optional.go` 2 | 3 | package main 4 | 5 | import "fmt" 6 | 7 | func strPtr(s string) *string { 8 | return &s 9 | } 10 | 11 | func create(b bool) *string { 12 | if (b) { 13 | return strPtr("Hello there") 14 | } else { 15 | return nil 16 | } 17 | } 18 | 19 | func main() { 20 | // method 1 21 | create_true := create(true) 22 | if (create_true != nil) { 23 | fmt.Printf("create(true) returned %s\n", *create_true) 24 | } 25 | 26 | // method 2 27 | create_false := create(false) 28 | var string_to_print string 29 | 30 | if (create_false != nil) { 31 | string_to_print = *create_false 32 | } else { 33 | string_to_print = "" 34 | } 35 | 36 | fmt.Printf("create(false) returned %s\n", string_to_print) 37 | } 38 | -------------------------------------------------------------------------------- /lec13/DataRace.java: -------------------------------------------------------------------------------- 1 | class DataRace { 2 | static final int N_THREADS = 50; 3 | static final int N_INCREMENTS = 100000; 4 | 5 | static int my_number = 0; 6 | 7 | static void thread() { 8 | for (int i = 0; i < N_INCREMENTS; i++) { 9 | my_number += 1; 10 | } 11 | } 12 | 13 | public static void main(String[] args) throws InterruptedException { 14 | Thread[] threads = new Thread[N_THREADS]; 15 | 16 | for (int i = 0; i < N_THREADS; i++) { 17 | threads[i] = new Thread(DataRace::thread); 18 | threads[i].start(); 19 | } 20 | for (int i = 0; i < N_THREADS; i++) { 21 | threads[i].join(); 22 | } 23 | 24 | System.out.println(String.format("Final total: %d (expected %d)\n", my_number, N_THREADS * N_INCREMENTS)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lec17/exam_q5_24T3/src/main_alt.rs: -------------------------------------------------------------------------------- 1 | use exam_q5_lib::DedupNotifier; 2 | 3 | fn main() { 4 | let event1 = 1; 5 | let event2 = 2; 6 | 7 | let (snd1, rcv1) = std::sync::mpsc::channel(); 8 | let (snd2, rcv2) = std::sync::mpsc::channel(); 9 | 10 | let mut dn = DedupNotifier::new(|event| event); 11 | println!("Add first listener and test."); 12 | dn.add_listener(snd1); 13 | dn.notify(event1); 14 | println!("Add second listener and test different word."); 15 | dn.add_listener(snd2); 16 | dn.notify(event2); 17 | println!("Now test the same word as the first time."); 18 | dn.notify(event1); 19 | 20 | println!("1/1: {:?}", rcv1.recv().unwrap()); 21 | println!("1/2: {:?}", rcv1.recv().unwrap()); 22 | 23 | println!("2/1: {:?}", rcv2.recv().unwrap()); 24 | println!("2/2: {:?}", rcv2.recv().unwrap()); 25 | 26 | println!("Done!") 27 | } 28 | -------------------------------------------------------------------------------- /lec11/rust/src/sort.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | use paste::paste; 4 | 5 | macro_rules! declare_sort { 6 | ($prefix:ident, $type:ty) => { 7 | paste! { 8 | use std::cmp::Ordering; 9 | 10 | fn [<_declare_sort_ $prefix _compare>](x: &$type, y: &$type) -> Ordering { 11 | if x > y { 12 | Ordering::Greater 13 | } else if x < y { 14 | Ordering::Less 15 | } else { 16 | Ordering::Equal 17 | } 18 | } 19 | 20 | fn [<$prefix _sort>](slice: &mut [$type]) { 21 | slice.sort(); 22 | } 23 | } 24 | } 25 | } 26 | 27 | declare_sort!(int, i32); 28 | 29 | pub fn test_sort() { 30 | let mut xs = [6, 1, 3, 9, 10, 5, 2, 4, 8, 7]; 31 | int_sort(&mut xs); 32 | 33 | println!("Sorted: {xs:?}"); 34 | } 35 | -------------------------------------------------------------------------------- /lec02/optional/optional.c: -------------------------------------------------------------------------------- 1 | // build with clang optional.c -o optional 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // Create may return NULL in these circumstances: 8 | // - if b is true, then it will return non-NULL 9 | // - if b is false, then it will return NULL 10 | char *create(bool b) { 11 | if (b) { 12 | return "Hello there"; 13 | } else { 14 | return NULL; 15 | } 16 | } 17 | 18 | int main(void) { 19 | // method 1 20 | char *create_true = create(false); 21 | if (create_true != NULL) { 22 | printf("create(true) returned %s\n", create_true); 23 | } else { 24 | printf("create(true) returned \n"); 25 | } 26 | 27 | // method 2 28 | char *create_false = create(false); 29 | printf( 30 | "create(false) returned %s\n", 31 | create_false ? create_false : "" 32 | ); 33 | } 34 | -------------------------------------------------------------------------------- /lec17/exam_q5_24T3/src/main.rs: -------------------------------------------------------------------------------- 1 | use exam_q5_lib::DedupNotifier; 2 | 3 | fn main() { 4 | let event1 = (944784000, 1); 5 | let event2 = (971481600, 2); 6 | 7 | let (snd1, rcv1) = std::sync::mpsc::channel(); 8 | let (snd2, rcv2) = std::sync::mpsc::channel(); 9 | 10 | let mut dn = DedupNotifier::new(|event| event); 11 | println!("Add first listener and test."); 12 | dn.add_listener(snd1); 13 | dn.notify(event1); 14 | println!("Add second listener and test different word."); 15 | dn.add_listener(snd2); 16 | dn.notify(event2); 17 | println!("Now test the same word as the first time."); 18 | dn.notify(event1); 19 | 20 | println!("1/1: {:?}", rcv1.recv().unwrap()); 21 | println!("1/2: {:?}", rcv1.recv().unwrap()); 22 | 23 | println!("2/1: {:?}", rcv2.recv().unwrap()); 24 | println!("2/2: {:?}", rcv2.recv().unwrap()); 25 | 26 | println!("Done!") 27 | } 28 | -------------------------------------------------------------------------------- /lec17/exam_q2_24T3/src/main.rs: -------------------------------------------------------------------------------- 1 | use exam_q2_lib::{find_str, most_common}; 2 | 3 | fn main() { 4 | let list_of_strs = vec!["hello", "world", "correct", "correct"]; 5 | 6 | // Part 1: find_str 7 | // let search = String::from("correct"); 8 | // let result = find_str(&list_of_strs, &search); 9 | // drop(search); 10 | 11 | let result = { 12 | let search = String::from("correct"); 13 | find_str(&list_of_strs, &search) 14 | }; 15 | 16 | println!("find_str: {:?}", result); 17 | 18 | // Part 2: most_common 19 | 20 | // let list_of_strs = vec!["hello", "world", "correct", "correct"]; 21 | // let result = most_common(&list_of_strs); 22 | // drop(list_of_strs); 23 | 24 | let result = { 25 | let list_of_strs = vec!["hello", "world", "correct", "correct"]; 26 | most_common(&list_of_strs) 27 | }; 28 | 29 | println!("most_common: {:?}", result); 30 | } 31 | -------------------------------------------------------------------------------- /lec11/c/sort.c: -------------------------------------------------------------------------------- 1 | // Examples from: https://www.cs.yale.edu/homes/aspnes/pinewiki/C(2f)Macros.html 2 | 3 | #include 4 | #include 5 | 6 | #define DeclareSort(prefix, type) \ 7 | static int \ 8 | _DeclareSort_ ## prefix ## _Compare(const void *a, const void *b) \ 9 | { \ 10 | const type *aa; const type *bb; \ 11 | aa = a; bb = b; \ 12 | if(*aa < *bb) return -1; \ 13 | else if(*bb < *aa) return 1; \ 14 | else return 0; \ 15 | } \ 16 | \ 17 | void \ 18 | prefix ## _sort(type *a, int n)\ 19 | { \ 20 | qsort(a, n, sizeof(type), _DeclareSort_ ## prefix ## _Compare); \ 21 | } 22 | 23 | DeclareSort(int, int) 24 | DeclareSort(float, float) 25 | DeclareSort(double, double) 26 | DeclareSort(char, char) 27 | 28 | int main(void) { 29 | int array[] = { 6, 1, 3, 9, 10, 5, 2, 4, 8, 7 }; 30 | int_sort(array, 10); 31 | 32 | for (int i = 0; i < 10; i++) { 33 | printf("%d\n", array[i]); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lec13/FixRace.java: -------------------------------------------------------------------------------- 1 | class FixRace { 2 | static final int N_THREADS = 50; 3 | static final int N_INCREMENTS = 100000; 4 | 5 | static int my_number = 0; 6 | static Object mutex = new Object(); 7 | 8 | static void thread() { 9 | for (int i = 0; i < N_INCREMENTS; i++) { 10 | synchronized (mutex) { 11 | // mutex.lock(); 12 | my_number += 1; 13 | } // mutex.unlock(); 14 | } 15 | } 16 | 17 | public static void main(String[] args) throws InterruptedException { 18 | Thread[] threads = new Thread[N_THREADS]; 19 | 20 | for (int i = 0; i < N_THREADS; i++) { 21 | threads[i] = new Thread(FixRace::thread); 22 | threads[i].start(); 23 | } 24 | for (int i = 0; i < N_THREADS; i++) { 25 | threads[i].join(); 26 | } 27 | 28 | System.out.println(String.format("Final total: %d (expected %d)\n", my_number, N_THREADS * N_INCREMENTS)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lec17/exam_q6_24T3/unsafe_review/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::{ptr, ops::Deref}; 2 | 3 | pub struct Lazy { 4 | value: *mut Option, 5 | f: fn() -> T, 6 | } 7 | 8 | impl Lazy { 9 | pub fn new(f: fn() -> T) -> Lazy { 10 | let v = Box::new(None::); 11 | 12 | Self { 13 | value: Box::into_raw(v), 14 | f, 15 | } 16 | } 17 | } 18 | 19 | impl Deref for Lazy { 20 | type Target = T; 21 | 22 | fn deref(&self) -> &Self::Target { 23 | unsafe { 24 | // if the value is uninitialized, then initialize it! 25 | let value = self.value.read(); 26 | if value.is_none() { 27 | let value = (self.f)(); 28 | self.value.write(Some(value)); 29 | } 30 | std::mem::forget(value); 31 | 32 | // the value is initialized, give out a borrow 33 | (*self.value).as_ref().unwrap() 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lec07/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | pub mod point; 4 | mod another_file; 5 | mod stuff; 6 | mod stuff2; 7 | 8 | pub fn add(point: point::Point) -> i32 { 9 | point.x + point.y 10 | } 11 | 12 | impl point::Point { 13 | // fn hello(&self) { 14 | // println!("hello from {} {}", self.x, self.y); 15 | // } 16 | } 17 | 18 | 19 | mod my_module { 20 | pub struct Point { 21 | x: i32, 22 | y: i32, 23 | } 24 | 25 | pub(crate) enum Foo { 26 | A, 27 | B(i32), 28 | C { x: i32, y: f64 }, 29 | } 30 | 31 | impl Point { 32 | pub fn x(&self) -> i32 { 33 | self.x 34 | } 35 | 36 | pub fn y(&self) -> i32 { 37 | self.y 38 | } 39 | 40 | pub fn x_mut(&mut self) -> &mut i32 { 41 | &mut self.x 42 | } 43 | 44 | // pub fn set_x(&mut self, x: i32) { 45 | // self.x = x; 46 | // } 47 | } 48 | 49 | fn hello() { 50 | println!("hello!"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lec06/src/dangling.rs: -------------------------------------------------------------------------------- 1 | //! Source: The Book 2 | 3 | #[cfg(never)] 4 | fn dangling() { 5 | 6 | let r; // ---------+-- 'a 7 | // | 8 | { // | 9 | let x = 5; // -+-- 'b | 10 | r = &x; // | | 11 | } // -+ | 12 | // | 13 | println!("r: {}", r); // ---------+ 14 | } 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | // 'b "outlives" 'a 30 | // 31 | // a.k.a.: 32 | // 'b : 'a 33 | // 34 | // 'b: 'a 35 | // 36 | // 37 | // 'a, 'b, 'c 38 | // 39 | // 'a: 'c 40 | // 'b: 'c 41 | // 42 | 43 | fn ok() { 44 | let x = 5; // ----------+-- 'b 45 | // | 46 | let r = &x; // --+-- 'a | 47 | // | | 48 | println!("r: {}", r); // | | 49 | // --+ | 50 | } // ----------+ 51 | -------------------------------------------------------------------------------- /lec05/src/shared.rs: -------------------------------------------------------------------------------- 1 | fn string_chars_len(string: S) -> usize 2 | where 3 | S: AsRef, 4 | { 5 | string.as_ref().chars().count() 6 | } 7 | 8 | 9 | 10 | #[cfg(test)] 11 | mod tests { 12 | use super::string_chars_len; 13 | 14 | #[test] 15 | fn empty() { 16 | assert_eq!(string_chars_len(&String::from("")), 0); 17 | } 18 | 19 | #[test] 20 | fn ascii() { 21 | assert_eq!(string_chars_len(&String::from("a")), 1); 22 | assert_eq!(string_chars_len(&String::from("ab")), 2); 23 | assert_eq!(string_chars_len(&String::from("abc")), 3); 24 | assert_eq!(string_chars_len(&String::from("abcd")), 4); 25 | } 26 | 27 | #[test] 28 | fn emoji() { 29 | assert_eq!(string_chars_len(&String::from("😀😃😄😁😆")), 5); 30 | } 31 | 32 | #[test] 33 | fn foo() { 34 | let mut string = String::from("hello"); 35 | let count = string_chars_len(&string); 36 | 37 | string.push_str(" world"); 38 | assert_eq!(string, "hello world"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lec06/src/slice.rs: -------------------------------------------------------------------------------- 1 | fn sum_array(list: [i32; 10]) -> i32 { 2 | let mut sum = 0; 3 | 4 | for elem in list { 5 | sum += elem; 6 | } 7 | 8 | sum 9 | } 10 | 11 | fn sum_vec(list: Vec) -> i32 { 12 | let mut sum = 0; 13 | 14 | for elem in list { 15 | sum += elem; 16 | } 17 | 18 | sum 19 | } 20 | 21 | fn sum_slice(list: &[i32]) -> i32 { 22 | let mut sum = 0; 23 | 24 | for elem in list { 25 | sum += elem; 26 | } 27 | 28 | sum 29 | } 30 | 31 | 32 | fn first_word(string: &str) -> &str { 33 | string.split_whitespace().next().unwrap_or(string) 34 | } 35 | 36 | 37 | 38 | 39 | 40 | #[cfg(test)] 41 | mod tests { 42 | use super::{sum_slice, first_word}; 43 | 44 | #[test] 45 | fn test1() { 46 | let array = [1, 2, 3, 4, 5]; 47 | let slice = &array[1..4]; 48 | 49 | assert_eq!(sum_slice(&vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 55); 50 | assert_eq!(sum_slice(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 55); 51 | assert_eq!(sum_slice(slice), 9); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lec13/fix_race.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define N_THREADS 50 6 | #define N_INCREMENTS 100000 7 | 8 | // Make sure to lock mutex before accessing this variable 9 | int my_number = 0; 10 | // mut-ual ex-clusivity 11 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 12 | 13 | void *thread(void *data) { 14 | for (int i = 0; i < N_INCREMENTS; i++) { 15 | pthread_mutex_lock(&mutex); 16 | my_number += 1; 17 | pthread_mutex_unlock(&mutex); 18 | } 19 | 20 | return NULL; 21 | } 22 | 23 | int main(void) { 24 | pthread_t *thrs = malloc(sizeof(pthread_t) * N_THREADS); 25 | 26 | for (int i = 0; i < N_THREADS; i++) { 27 | pthread_create(&thrs[i], NULL, thread, NULL); 28 | } 29 | for (int i = 0; i < N_THREADS; i++) { 30 | pthread_join(thrs[i], NULL); 31 | } 32 | 33 | 34 | pthread_mutex_lock(&mutex); 35 | printf("Final total: %d (expected %d)\n", my_number, N_THREADS * N_INCREMENTS); 36 | pthread_mutex_unlock(&mutex); 37 | 38 | free(thrs); 39 | } 40 | -------------------------------------------------------------------------------- /lec11/rust/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | mod sort; 4 | 5 | // #define ADD5(x) x + 5 6 | 7 | macro_rules! add5 { 8 | ($x:expr) => { 9 | $x + 5 10 | }; 11 | } 12 | 13 | macro_rules! mul7 { 14 | ($x:expr) => { 15 | $x * 7 16 | }; 17 | } 18 | 19 | macro_rules! max { 20 | ($x:expr, $y:expr) => { 21 | if $x > $y { $x } else { $y } 22 | }; 23 | } 24 | 25 | macro_rules! my_vec { 26 | [] => { 27 | Vec::new() 28 | }; 29 | [$($item:expr),+ $(,)?] => { 30 | { 31 | let mut v = Vec::new(); 32 | $( 33 | v.push($item); 34 | )+ 35 | v 36 | } 37 | } 38 | } 39 | 40 | fn main() { 41 | let x = mul7!(add5!{2}); 42 | let y = max!(dbg!(x), dbg![42]); 43 | println!("{y}"); 44 | 45 | let std_vec = vec!{ 46 | 1, 47 | 2, 48 | 3, 49 | }; 50 | println!("{std_vec:?}"); 51 | 52 | let my_vec = my_vec![ 53 | 1, 54 | 2, 55 | 3, 56 | 4, 57 | 5, 58 | ]; 59 | 60 | println!("{my_vec:?}"); 61 | } 62 | -------------------------------------------------------------------------------- /lec13/rust-race/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | use std::{sync::mpsc::channel, thread::{self, sleep}, time::Duration}; 4 | 5 | mod data_race; 6 | mod unsafe_race; 7 | 8 | fn main() { 9 | // concurrency_example(); 10 | 11 | // data_race::attempt1::main(); 12 | // data_race::attempt2::main(); 13 | // data_race::attempt3::main(); 14 | // data_race::attempt5::main(); 15 | // data_race::attempt4fix1::main(); 16 | // data_race::attempt4fix2::main(); 17 | // data_race::attempt5::main(); 18 | 19 | // unsafe_race::main(); 20 | } 21 | 22 | fn concurrency_example() { 23 | let handle1 = std::thread::spawn(task1); 24 | let handle2 = std::thread::spawn(task2); 25 | 26 | handle1.join().unwrap(); 27 | handle2.join().unwrap(); 28 | } 29 | 30 | fn task1() { 31 | loop { 32 | let mut input = String::new(); 33 | std::io::stdin().read_line(&mut input); 34 | println!("you said: {input}"); 35 | } 36 | } 37 | 38 | fn task2() { 39 | loop { 40 | println!("hello"); 41 | std::thread::sleep(Duration::from_secs(2)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lec14/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::{sync::mpsc, thread}; 2 | 3 | use rayon::iter::{ParallelIterator, IntoParallelIterator}; 4 | 5 | fn main() { 6 | let answer: f64 = (0_u64..100_000_000_000) 7 | .into_par_iter() 8 | .map(|x| x as f64) 9 | .sum(); 10 | 11 | println!("{answer}"); 12 | } 13 | 14 | 15 | /* 16 | let (send, recv) = mpsc::channel(); 17 | 18 | let mut thread_handles = vec![]; 19 | for i in 0..5 { 20 | let send = send.clone(); 21 | 22 | let handle = thread::spawn(move || { 23 | send.send(format!("hello from thread {i}")).unwrap(); 24 | }); 25 | thread_handles.push(handle); 26 | } 27 | drop(send); 28 | 29 | thread::spawn(move || { 30 | while let Ok(message) = recv.recv() { 31 | println!("I received a message: {message}"); 32 | } 33 | }).join().unwrap(); 34 | 35 | for handle in thread_handles { 36 | handle.join().unwrap(); 37 | } 38 | } 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | */ 68 | -------------------------------------------------------------------------------- /lec11/yew-demo/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) Zac Kologlu 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /lec17/exam_q5_24T3/src/main_alt2.rs: -------------------------------------------------------------------------------- 1 | use exam_q5_lib::DedupNotifier; 2 | 3 | #[derive(Debug, Clone, Copy)] 4 | struct Event { 5 | time: i64, 6 | event_id: i64, 7 | } 8 | 9 | fn hasher(event: Event) -> i64 { 10 | event.time + event.event_id 11 | } 12 | 13 | fn main() { 14 | let event1 = Event { 15 | time: 944784000, 16 | event_id: 1, 17 | }; 18 | let event2 = Event { 19 | time: 971481600, 20 | event_id: 2, 21 | }; 22 | 23 | let (snd1, rcv1) = std::sync::mpsc::channel(); 24 | let (snd2, rcv2) = std::sync::mpsc::channel(); 25 | 26 | let mut dn = DedupNotifier::new(hasher); 27 | println!("Add first listener and test."); 28 | dn.add_listener(snd1); 29 | dn.notify(event1.clone()); 30 | println!("Add second listener and test different word."); 31 | dn.add_listener(snd2); 32 | dn.notify(event2); 33 | println!("Now test the same word as the first time."); 34 | dn.notify(event1); 35 | 36 | println!("1/1: {:?}", rcv1.recv().unwrap()); 37 | println!("1/2: {:?}", rcv1.recv().unwrap()); 38 | 39 | println!("2/1: {:?}", rcv2.recv().unwrap()); 40 | println!("2/2: {:?}", rcv2.recv().unwrap()); 41 | 42 | println!("Done!") 43 | } 44 | -------------------------------------------------------------------------------- /lec17/exam_q5_24T3/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::sync::mpsc::Sender; 2 | 3 | /// The Event type represents a pair of time and event_id. 4 | pub type Event = (u64, u64); 5 | 6 | struct Listener { 7 | sender: Sender, 8 | prev_hashes: Vec, 9 | } 10 | 11 | pub struct DedupNotifier { 12 | listeners: Vec, 13 | hasher: fn(Event) -> Event, 14 | } 15 | 16 | impl DedupNotifier { 17 | pub fn new(hasher: fn(Event) -> Event) -> Self { 18 | Self { 19 | hasher: hasher, 20 | listeners: Vec::new(), 21 | } 22 | } 23 | 24 | pub fn add_listener(&mut self, notifier: Sender) { 25 | self.listeners.push(Listener { 26 | sender: notifier, 27 | prev_hashes: Vec::new(), 28 | }); 29 | } 30 | 31 | pub fn notify(&mut self, message: Event) { 32 | let hash = (self.hasher)(message.clone()); 33 | self.listeners.iter_mut().for_each(|listener| { 34 | if listener.prev_hashes.contains(&hash) { 35 | return; 36 | } else { 37 | listener.prev_hashes.push(hash); 38 | } 39 | listener.sender.send(message.clone()).unwrap(); 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lec12/lec12-extension-trait/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | use std::{thread, time::{Duration, Instant}}; 4 | 5 | fn main() { 6 | let mut factor = 2.5; 7 | let closure = |x: i32| { 8 | let factor = &mut factor; 9 | 10 | let res = x as f64 * *factor; 11 | *factor += 1.0; 12 | res 13 | }; 14 | 15 | 16 | let result = [1, 2, 3].into_iter() 17 | .my_map(closure) 18 | .collect::>(); 19 | 20 | println!("{result:?}"); 21 | } 22 | 23 | 24 | struct MyMap { 25 | iter: I, 26 | f: F, 27 | } 28 | 29 | 30 | trait MyMapExt: Sized { 31 | fn my_map(self, f: F) -> MyMap; 32 | } 33 | 34 | impl MyMapExt for I 35 | where 36 | I: Iterator, 37 | { 38 | fn my_map(self, f: F) -> MyMap { 39 | MyMap { iter: self, f } 40 | } 41 | } 42 | 43 | 44 | 45 | impl Iterator for MyMap 46 | where 47 | I: Iterator, 48 | F: FnMut(CurrItem) -> NewItem, 49 | { 50 | type Item = NewItem; 51 | 52 | fn next(&mut self) -> Option { 53 | let curr = self.iter.next()?; 54 | let new = (self.f)(curr); 55 | 56 | Some(new) 57 | } 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /lec01/lines/src/main.rs: -------------------------------------------------------------------------------- 1 | use bmp::{Image, Pixel}; 2 | 3 | const IMAGE_SIZE_PX: u32 = 256; 4 | 5 | fn main() { 6 | let mut my_image = Image::new(IMAGE_SIZE_PX, IMAGE_SIZE_PX); 7 | 8 | let red = create_pixel(255, 0, 0); 9 | let green = create_pixel(0, 255, 0); 10 | let blue = create_pixel(0, 0, 255); 11 | let black = create_pixel(0, 0, 0); 12 | 13 | for x in 0..IMAGE_SIZE_PX { 14 | for y in 0..IMAGE_SIZE_PX { 15 | let colour = if (x + y) % 15 == 0 { 16 | red 17 | } else if (x + y) % 15 == 5 { 18 | green 19 | } else if (x + y) % 15 == 10 { 20 | blue 21 | } else { 22 | black 23 | }; 24 | 25 | // let colour = match (x + y) % 15 { 26 | // 0 => red, 27 | // 5 => green, 28 | // 10 => blue, 29 | // _ => black, 30 | // }; 31 | 32 | my_image.set_pixel(x, y, colour); 33 | } 34 | } 35 | 36 | let result = my_image.save("my_image.bmp"); 37 | result.expect("Failed to save image"); 38 | } 39 | 40 | fn create_pixel(r: u8, g: u8, b: u8) -> Pixel { 41 | let pixel = Pixel::new(r, g, b); 42 | return pixel; 43 | } 44 | -------------------------------------------------------------------------------- /lec17/exam_q4_24T3/q4_3/src/main.rs: -------------------------------------------------------------------------------- 1 | macro_rules! map { 2 | ($($tokens:tt)*) => { 3 | { 4 | let mut map = ::std::collections::BTreeMap::new(); 5 | 6 | map_inner!(map; $($tokens)*); 7 | 8 | map 9 | } 10 | }; 11 | } 12 | 13 | // recursive tt munching 14 | macro_rules! map_inner { 15 | ($map:expr; ) => { 16 | 17 | }; 18 | ($map:expr; $key:expr => $value:expr,$($rest:tt)*) => { 19 | $map.insert($key, $value); 20 | 21 | map_inner!($map; $($rest)*); 22 | }; 23 | ($map:expr; $key:expr => ref $ref_key:expr,$($rest:tt)*) => { 24 | let val = *$map.get(&$ref_key).unwrap(); 25 | $map.insert($key, val); 26 | 27 | map_inner!($map; $($rest)*); 28 | }; 29 | } 30 | 31 | fn main() { 32 | let map = map![ 33 | 0 => "a", 34 | 1 => ref 0, 35 | 2 => "b", 36 | 3 => ref 1, 37 | ]; 38 | 39 | // The code above expands into: 40 | // let map = { 41 | // let mut map = ::std::collections::BTreeMap::new(); 42 | 43 | // map.insert(0, "a"); 44 | // map.insert(1, "b"); 45 | // map.insert(2, "c"); 46 | 47 | // map 48 | // }; 49 | 50 | // Prints: {0: "a", 1: "b", 2: "c"} 51 | println!("{map:?}"); 52 | } 53 | -------------------------------------------------------------------------------- /lec17/exam_q5_24T3/src/main_alt3.rs: -------------------------------------------------------------------------------- 1 | use exam_q5_lib::DedupNotifier; 2 | 3 | #[derive(Debug, Clone)] 4 | struct Event { 5 | time: i64, 6 | event_id: i64, 7 | text: String, 8 | } 9 | 10 | fn main() { 11 | let event1 = Event { 12 | time: 944784000, 13 | event_id: 1, 14 | text: "Happy Birthday Tom".to_string(), 15 | }; 16 | let event2 = Event { 17 | time: 971481600, 18 | event_id: 2, 19 | text: "Happy Birthday Zac".to_string(), 20 | }; 21 | 22 | let (snd1, rcv1) = std::sync::mpsc::channel(); 23 | let (snd2, rcv2) = std::sync::mpsc::channel(); 24 | 25 | let mut dn = DedupNotifier::new(|event: Event| event.time + event.event_id); 26 | println!("Add first listener and test."); 27 | dn.add_listener(snd1); 28 | dn.notify(event1.clone()); 29 | println!("Add second listener and test different word."); 30 | dn.add_listener(snd2); 31 | dn.notify(event2); 32 | println!("Now test the same word as the first time."); 33 | dn.notify(event1); 34 | 35 | println!("1/1: {:?}", rcv1.recv().unwrap().text); 36 | println!("1/2: {:?}", rcv1.recv().unwrap().text); 37 | 38 | println!("2/1: {:?}", rcv2.recv().unwrap().text); 39 | println!("2/2: {:?}", rcv2.recv().unwrap().text); 40 | 41 | println!("Done!") 42 | } 43 | -------------------------------------------------------------------------------- /lec17/exam_q4_24T3/q4_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | spam_text_2("Hello, world!"); 3 | } 4 | 5 | use std::thread; 6 | 7 | fn spam_text_1(message: &str) { 8 | let mut handles = Vec::new(); 9 | 10 | for _ in 0..5 { 11 | let message_owned = message.to_string(); 12 | let handle = thread::spawn(move || { 13 | for _ in 0..20 { 14 | println!("{message_owned}"); 15 | } 16 | }); 17 | handles.push(handle); 18 | } 19 | 20 | for handle in handles { 21 | handle.join().unwrap(); 22 | } 23 | } 24 | 25 | fn spam_text_2(message: &str) { 26 | thread::scope(|scope| { 27 | for _ in 0..5 { 28 | scope.spawn(|| { 29 | for _ in 0..20 { 30 | println!("{message}"); 31 | } 32 | }); 33 | } 34 | }); 35 | } 36 | 37 | 38 | fn spam_text_3(message: &str) { 39 | let message: &'static str = Box::leak(message.to_string().into_boxed_str()); 40 | 41 | let mut handles = Vec::new(); 42 | 43 | for _ in 0..5 { 44 | let handle = thread::spawn(move || { 45 | for _ in 0..20 { 46 | println!("{message}"); 47 | } 48 | }); 49 | handles.push(handle); 50 | } 51 | 52 | for handle in handles { 53 | handle.join().unwrap(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lec11/program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo 1 3 | echo 2 4 | echo 3 5 | echo 4 6 | echo 5 7 | echo 6 8 | echo 7 9 | echo 8 10 | echo 9 11 | echo 10 12 | echo 11 13 | echo 12 14 | echo 13 15 | echo 14 16 | echo 15 17 | echo 16 18 | echo 17 19 | echo 18 20 | echo 19 21 | echo 20 22 | echo 21 23 | echo 22 24 | echo 23 25 | echo 24 26 | echo 25 27 | echo 26 28 | echo 27 29 | echo 28 30 | echo 29 31 | echo 30 32 | echo 31 33 | echo 32 34 | echo 33 35 | echo 34 36 | echo 35 37 | echo 36 38 | echo 37 39 | echo 38 40 | echo 39 41 | echo 40 42 | echo 41 43 | echo 42 44 | echo 43 45 | echo 44 46 | echo 45 47 | echo 46 48 | echo 47 49 | echo 48 50 | echo 49 51 | echo 50 52 | echo 51 53 | echo 52 54 | echo 53 55 | echo 54 56 | echo 55 57 | echo 56 58 | echo 57 59 | echo 58 60 | echo 59 61 | echo 60 62 | echo 61 63 | echo 62 64 | echo 63 65 | echo 64 66 | echo 65 67 | echo 66 68 | echo 67 69 | echo 68 70 | echo 69 71 | echo 70 72 | echo 71 73 | echo 72 74 | echo 73 75 | echo 74 76 | echo 75 77 | echo 76 78 | echo 77 79 | echo 78 80 | echo 79 81 | echo 80 82 | echo 81 83 | echo 82 84 | echo 83 85 | echo 84 86 | echo 85 87 | echo 86 88 | echo 87 89 | echo 88 90 | echo 89 91 | echo 90 92 | echo 91 93 | echo 92 94 | echo 93 95 | echo 94 96 | echo 95 97 | echo 96 98 | echo 97 99 | echo 98 100 | echo 99 101 | echo 100 102 | -------------------------------------------------------------------------------- /lec01/lines/lines.c: -------------------------------------------------------------------------------- 1 | // Gives us `struct image`, `struct pixel`, `save_image` 2 | #include "bmp.h" 3 | 4 | #define IMAGE_SIZE_PX 256 5 | 6 | struct pixel create_pixel(int r, int g, int b); 7 | 8 | int main(void) { 9 | struct image my_image; 10 | my_image.width = IMAGE_SIZE_PX; 11 | my_image.height = IMAGE_SIZE_PX; 12 | 13 | struct pixel red = create_pixel(255, 0, 0); 14 | struct pixel green = create_pixel(0, 255, 0); 15 | struct pixel blue = create_pixel(0, 0, 255); 16 | struct pixel black = create_pixel(0, 0, 0); 17 | 18 | for (int x = 0; x < IMAGE_SIZE_PX; x++) { 19 | for (int y = 0; y < IMAGE_SIZE_PX; y++) { 20 | if ((x + y) % 15 == 0) { 21 | set_pixel(image, x, y, red); 22 | } else if ((x + y) % 15 == 5) { 23 | set_pixel(image, x, y, green); 24 | } else if ((x + y) % 15 == 10) { 25 | set_pixel(image, x, y, blue); 26 | } else { 27 | set_pixel(image, x, y, black); 28 | } 29 | } 30 | } 31 | 32 | int result = save_image(image, "my_image.bmp"); 33 | if (result != 0) { 34 | fputs(stderr, "Failed to save image!\n"); 35 | return 1; 36 | } 37 | 38 | return 0; 39 | } 40 | 41 | struct pixel create_pixel(int r, int g, int b) { 42 | struct pixel pixel; 43 | 44 | pixel.r = r; 45 | pixel.g = g; 46 | pixel.b = b; 47 | 48 | return pixel; 49 | } 50 | -------------------------------------------------------------------------------- /lec09/traits/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Crab { 2 | name: String, 3 | shell_count: i32, 4 | has_shell: bool, 5 | } 6 | 7 | struct Mouse { 8 | name: String, 9 | age: i32, 10 | cheese: bool, 11 | } 12 | impl Speak for Mouse { 13 | fn speak(&self) -> String { 14 | String::from("Squeak!") 15 | } 16 | } 17 | 18 | struct Cow { 19 | name: String, 20 | age: i32, 21 | is_mooing: bool, 22 | } 23 | 24 | impl Speak for Cow { 25 | fn speak(&self) -> String { 26 | String::from("MOooooo!") 27 | } 28 | } 29 | 30 | trait Speak { 31 | fn speak(&self) -> String; 32 | } 33 | 34 | fn speak_to_eachother(animals: Vec>) { 35 | for a in animals { 36 | dbg!(a.speak()); 37 | } 38 | } 39 | 40 | /* Not extesible! 41 | enum Animal { 42 | Cow(Cow), 43 | Mouse(Mouse), 44 | }*/ 45 | 46 | fn main() { 47 | let c1 = Box::new(Cow { 48 | name: String::from("Tom"), 49 | age: 100, 50 | is_mooing: true, 51 | }); 52 | let m2 = Box::new(Mouse { 53 | name: String::from("Mot"), 54 | age: 100, 55 | cheese: true, 56 | }); 57 | dbg!(speak_to_eachother(vec![c1, m2])); 58 | 59 | println!("Hello, world!"); 60 | } 61 | 62 | trait ExistsIn2DSpace {} 63 | trait Movable {} 64 | 65 | impl Add for T {} 66 | 67 | impl Add for Coordinate {} 68 | 69 | mod new_lib { 70 | trait IsInASpace {} 71 | 72 | impl Add for T {} 73 | } 74 | -------------------------------------------------------------------------------- /lec03/playing_around/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | x: i32, 3 | y: char, 4 | z: [i32; 5], 5 | } 6 | 7 | // type FooTuple = (i32, char, f32); 8 | 9 | fn main() { 10 | let number = 42; 11 | let number2 = number; 12 | println!("{number}"); 13 | 14 | // let string = String::from("hello"); 15 | // let string2 = string; 16 | // println!("{string}"); 17 | 18 | let y = (42,); 19 | 20 | let mut x: (i32, char, f32) = (42, 'x', 3.14); 21 | let (mut n, c, mut f) = x; 22 | // (n, c, f) = (42, 'x', 3.14) 23 | println!("{n} {c} {f}"); 24 | let (n, ..) = x; 25 | let (_, c, _) = x; 26 | let (.., f) = x; 27 | 28 | let n = x.0; 29 | let c = x.1; 30 | let f = x.2; 31 | 32 | x.0 = 123; 33 | 34 | println!("{x:?}"); 35 | println!("{:?}", x); 36 | 37 | let y: [i32; 5] = [1, 2, 3, 4, 5]; 38 | let x: bool = false; 39 | let z: () = (); 40 | 41 | println!("{}", if x { 42 } else { 123 }); 42 | let z = if x { 43 | 42 44 | } else { 45 | 123 46 | }; 47 | 48 | let x = loop { 49 | // ... 50 | break; 51 | }; 52 | 53 | //while some_fn_returns_true() { 54 | 55 | //} 56 | 57 | 58 | // let foo = Foo { 59 | // x: 5, 60 | // y: 'y', 61 | // }; 62 | 63 | // match x { 64 | // 0 => {} 65 | // 1 => {} 66 | // 2 => {} 67 | // _ => {} 68 | // } 69 | 70 | println!("Hello, world!"); 71 | } 72 | -------------------------------------------------------------------------------- /lec03/collections/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | fn main() { 4 | let xs1 = vec![2, 5, 9, 11, 15, 16]; 5 | let xs2 = vec![-1, 0, 1]; 6 | 7 | let mean1 = find_the_mean(xs1.clone()); 8 | let mean2 = find_the_mean(xs2); 9 | let mean3 = find_the_mean(xs1).unwrap_or(0.0); 10 | println!("The mean is {mean1:?}"); 11 | println!("The mean is {mean2:?}"); 12 | println!("The mean is {mean3:?}"); 13 | } 14 | 15 | /// This function will not return NaN 16 | /// 17 | /// This function will return None if the provided `vec` is empty. 18 | fn find_the_mean(vec: Vec) -> Option { 19 | if vec.is_empty() { 20 | return None; 21 | } 22 | 23 | let mut sum = 0; 24 | 25 | for elem in vec.clone() { 26 | sum += elem; 27 | } 28 | 29 | Some(sum as f64 / vec.len() as f64) 30 | } 31 | 32 | // sum as f64 / usize::max(vec.len(), 1) as f64 33 | // if average.is_nan() { 34 | // return None; 35 | // } 36 | // 37 | // Some(average) 38 | 39 | fn find_the_median(vec: Vec) -> f64 { 40 | // vec.len() => length 41 | // vec[index] -- what could go wrong? what type does it return? 42 | // vec.get(...) -- what type does it return? 43 | 44 | todo!() 45 | } 46 | 47 | // fn find_the_mean(vec: Vec) -> f64 { 48 | // let mut sum = 0; 49 | // let len = vec.len(); 50 | // 51 | // for elem in vec { 52 | // sum += elem; 53 | // } 54 | // 55 | // return sum as f64 / len as f64; 56 | // } 57 | -------------------------------------------------------------------------------- /lec17/exam_q3_24T3/q3_3.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | trait Animal { ... } 5 | struct Dog; 6 | struct Cat; 7 | 8 | struct Foo 9 | where A: Animal { 10 | animals: Vec, 11 | } 12 | struct Foo { 13 | animals: Vec, 14 | } 15 | 16 | 1. 17 | `Visitor` is used without a type parameter 18 | or the dyn keyword. It is a trait, not a type! 19 | 20 | 2. 21 | 22 | mod plugins; 23 | 24 | // These types implement the `Visitor` trait 25 | use plugins::{QuerySelectorTransformer, ServerSideTransformer}; 26 | 27 | struct Transformer { 28 | plugins: Vec, 29 | } 30 | 31 | struct Plugin { 32 | // change this to dyn vvv 33 | visitor: Box, 34 | } 35 | 36 | trait Visitor { 37 | fn visit(&self, source: String) -> String; 38 | } 39 | 40 | pub fn transform_code(code: String) -> String { 41 | let transformer = Transformer { 42 | plugins: vec![ 43 | Plugin { 44 | // wrap in a Box vvv 45 | visitor: Box::new(QuerySelectorTransformer), 46 | }, 47 | Plugin { 48 | // wrap in a Box vvv 49 | visitor: Box::new(ServerSideTransformer), 50 | }, 51 | ], 52 | }; 53 | 54 | let transformed_code = transformer.run(code); 55 | 56 | transformed_code 57 | } 58 | 59 | impl Transformer { 60 | fn run(self, mut code: String) -> String { 61 | for plugin in self.plugins { 62 | code = plugin.visitor.visit(code); 63 | } 64 | 65 | code 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lec05/src/exclusive.rs: -------------------------------------------------------------------------------- 1 | /// # Emphasize 2 | /// 3 | /// Emphasize should take a `String`, 4 | /// and mutate the following: 5 | /// 6 | /// * Make any ASCII characters uppercase 7 | /// * Append "!!!" to the end 8 | /// 9 | /// For example: 10 | /// 11 | /// ``` 12 | /// let mut s = String::from("test"); 13 | /// emphasize(&mut s); 14 | /// 15 | /// assert_eq!(s, "TEST!!!"); 16 | /// ``` 17 | fn emphasize(string: &mut String) { 18 | string.make_ascii_uppercase(); 19 | string.push_str("!!!"); 20 | } 21 | 22 | 23 | 24 | 25 | 26 | #[cfg(test)] 27 | mod tests { 28 | use super::emphasize; 29 | 30 | #[test] 31 | fn empty() { 32 | let mut s = String::from(""); 33 | emphasize(&mut s); 34 | 35 | assert_eq!(s, "!!!"); 36 | } 37 | 38 | #[test] 39 | fn ascii() { 40 | let mut s = String::from("a"); 41 | emphasize(&mut s); 42 | assert_eq!(s, "A!!!"); 43 | 44 | let mut s = String::from("aB"); 45 | let excl_borrow_1 = &mut s; 46 | emphasize(excl_borrow_1); 47 | assert_eq!(s, "AB!!!"); 48 | 49 | let mut s = String::from("aBc"); 50 | emphasize(&mut s); 51 | 52 | assert_eq!(s, "ABC!!!"); 53 | 54 | let mut s = String::from("Hello, World!"); 55 | emphasize(&mut s); 56 | 57 | assert_eq!(s, "HELLO, WORLD!!!!"); 58 | } 59 | 60 | #[test] 61 | fn emoji() { 62 | let mut s = String::from("😀😃😄😁😆"); 63 | emphasize(&mut s); 64 | 65 | assert_eq!(s, "😀😃😄😁😆!!!"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lec06/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | // mod dangling; 4 | // mod slice; 5 | mod longest; 6 | 7 | struct Foo { 8 | x: i32, 9 | } 10 | 11 | impl Drop for Foo { 12 | fn drop(&mut self) { 13 | println!("dropping Foo with x={}", self.x); 14 | } 15 | } 16 | 17 | fn drop(t: T) {} 18 | 19 | fn main() { 20 | 21 | let b = Box::new(42); 22 | // int *b = malloc(sizeof(int)); 23 | // *b = 42; 24 | 25 | println!("before scope"); 26 | { 27 | let foo = Foo { x: 42 }; 28 | 29 | } 30 | println!("after scope"); 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | /* 43 | fn main() { 44 | let mut student = Student { name: String::from("zac"), address: String::from("hello st"), ph: String::from("04"), marks: vec![] }; 45 | 46 | let excl_borrow = &mut student; 47 | let marks = excl_borrow.marks; 48 | 49 | add_mark(&mut excl_borrow.marks, 100.0); 50 | 51 | let stolen_name = student.name; 52 | student.name = String::from("caz"); 53 | 54 | let stolen_address = &student.address; 55 | let stolen_ph = &student.ph; 56 | let stolen_address = &student.address; 57 | 58 | takes_student(student); 59 | } 60 | 61 | fn takes_student(student: Student) { todo!() } 62 | 63 | struct Student { 64 | name: String, 65 | address: String, 66 | ph: String, 67 | marks: Vec, 68 | } 69 | 70 | fn add_mark(student: &Student, mark: f64) { 71 | let marks_vec = &student.marks; 72 | Vec::push(&mut student.marks, mark); 73 | student.marks.push(mark); 74 | } 75 | */ 76 | -------------------------------------------------------------------------------- /lec06/src/longest.rs: -------------------------------------------------------------------------------- 1 | // fn longest<'a, 'b, 'c>(x: &'a str, y: &'b str) -> &'c str 2 | // where 3 | // 'a: 'c, 4 | // 'b: 'c, 5 | // { 6 | // if x.len() >= y.len() { 7 | // x 8 | // } else { 9 | // y 10 | // } 11 | // } 12 | 13 | // struct Longest<'a> { 14 | // longest: &'a str, 15 | // } 16 | // 17 | // fn longest<'a>(x: &'a str, y: &'a str) -> Longest<'a> { 18 | // if x.len() >= y.len() { 19 | // Longest { longest: x } 20 | // } else { 21 | // Longest { longest: y } 22 | // } 23 | // } 24 | 25 | 26 | fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { 27 | if x.len() >= y.len() { 28 | x 29 | } else { 30 | y 31 | } 32 | } 33 | 34 | fn first<'a, 'b>(x: &'a str, y: &'b str) -> &'a str { 35 | x 36 | } 37 | 38 | fn gives_back(x: &str) -> &'static str { 39 | "hello" 40 | } 41 | 42 | // fn first<'a, 'b>(x: &'a str, y: &'b str) -> &'b str 43 | // where 44 | // 'a: 'b, 45 | // { 46 | // x 47 | // } 48 | 49 | fn main() { 50 | let longer; 51 | let firster; 52 | 53 | let long_lifetime_string = String::from("hello"); 54 | 55 | { 56 | 57 | { 58 | { 59 | let short_lifetime_string = String::from("world!"); 60 | 61 | longer = longest(&long_lifetime_string, &short_lifetime_string); 62 | firster = first(&long_lifetime_string, &short_lifetime_string); 63 | println!("{longer}"); 64 | } 65 | } 66 | 67 | 68 | println!("{firster}"); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lec02/optional/optional.rs: -------------------------------------------------------------------------------- 1 | // build with: rustc optional.rs 2 | 3 | 4 | fn create(b: bool) -> Option<&'static str> { 5 | if b { 6 | Some("Hello There") 7 | } else { 8 | None 9 | } 10 | } 11 | 12 | fn main() { 13 | // method 1 14 | let create_true = create(true); 15 | if create_true.is_some() { 16 | println!("create(true) returned {}", create_true.unwrap()); 17 | } 18 | 19 | // method 2 20 | println!( 21 | "create(false) returned {}", 22 | create(false).unwrap_or("") 23 | ); 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | // ... 33 | // ... 34 | // ... 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | let x: Option = None; 49 | // let x = Some(123); 50 | 51 | // let x: Option>> = Some(Some(Some(42))); 52 | 53 | 54 | // method 3 55 | let create_true: Option<&str> = create(true); 56 | match create_true { 57 | Some("") => println!("create(true) returned empty string"), 58 | Some(string) => println!("create(true) returned {string}"), 59 | Some("hello") => println!("create(true) returned hello"), 60 | None => println!("create(false) returned "), 61 | } 62 | 63 | 64 | let bools: (bool, bool) = (true, false); 65 | match bools { 66 | (left, right) => {} 67 | // (false, true) => {} 68 | // (true, false) => {} 69 | // (true, true) => {} 70 | } 71 | } 72 | 73 | 74 | // enum Option { 75 | // None, 76 | // Some(T), 77 | // } 78 | // use Option::None; 79 | // use Option::Some; 80 | // 81 | -------------------------------------------------------------------------------- /lec14/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "crossbeam-deque" 7 | version = "0.8.6" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" 10 | dependencies = [ 11 | "crossbeam-epoch", 12 | "crossbeam-utils", 13 | ] 14 | 15 | [[package]] 16 | name = "crossbeam-epoch" 17 | version = "0.9.18" 18 | source = "registry+https://github.com/rust-lang/crates.io-index" 19 | checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" 20 | dependencies = [ 21 | "crossbeam-utils", 22 | ] 23 | 24 | [[package]] 25 | name = "crossbeam-utils" 26 | version = "0.8.21" 27 | source = "registry+https://github.com/rust-lang/crates.io-index" 28 | checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" 29 | 30 | [[package]] 31 | name = "either" 32 | version = "1.15.0" 33 | source = "registry+https://github.com/rust-lang/crates.io-index" 34 | checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" 35 | 36 | [[package]] 37 | name = "lec14" 38 | version = "0.1.0" 39 | dependencies = [ 40 | "rayon", 41 | ] 42 | 43 | [[package]] 44 | name = "rayon" 45 | version = "1.10.0" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" 48 | dependencies = [ 49 | "either", 50 | "rayon-core", 51 | ] 52 | 53 | [[package]] 54 | name = "rayon-core" 55 | version = "1.12.1" 56 | source = "registry+https://github.com/rust-lang/crates.io-index" 57 | checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" 58 | dependencies = [ 59 | "crossbeam-deque", 60 | "crossbeam-utils", 61 | ] 62 | -------------------------------------------------------------------------------- /lec04/collections/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | use itertools::Itertools; 4 | 5 | fn main() { 6 | // Longest equal run: 3 7 | let input_1 = vec![1, 2, 3, 4, 5, 6, 7, 8]; 8 | let input_2 = vec![1, 2, 1, 4, 5, 6, 4, 8]; 9 | 10 | dbg!(longest_equal_run_mixed(input_1, input_2)); 11 | } 12 | 13 | fn longest_equal_run_imperative(x: Vec, y: Vec) -> usize { 14 | let len = usize::min(x.len(), y.len()); 15 | 16 | let mut current_run = 0; 17 | let mut longest_run = 0; 18 | 19 | let mut i = 0; 20 | while i < len { 21 | if x[i] == y[i] { 22 | current_run += 1; 23 | 24 | if current_run > longest_run { 25 | longest_run = current_run; 26 | } 27 | } else { 28 | current_run = 0; 29 | } 30 | 31 | i += 1; 32 | } 33 | 34 | longest_run 35 | } 36 | 37 | // fn is_equal((x, y): (i32, i32)) -> bool { 38 | // x == y 39 | // } 40 | 41 | // [1, 2, 3, 4, 5, 6, 7, 8]; 42 | // [1, 2, 1, 4, 5, 6, 4, 8]; 43 | fn longest_equal_run_functional(x: Vec, y: Vec) -> usize { 44 | x.into_iter().zip(y.into_iter()) // [(1, 1), (2, 2), (3, 1), (4, 4), (5, 5), (6, 6), (7, 4), (8, 8)] 45 | .map(|(x, y)| x == y) // [T, T, F, T, T, T, F, T] 46 | .dedup_with_count() // [(2, T), (1, F), (3, T), (1, F), (1, T)] 47 | .filter(|(length, equal)| *equal) // [(2, T), (3, T), (1, T)] 48 | .map(|(length, equal)| length) // [2, 3, 1] 49 | .max() 50 | .unwrap_or(0) 51 | } 52 | 53 | fn longest_equal_run_mixed(x: Vec, y: Vec) -> usize { 54 | let mut current_run = 0; 55 | let mut longest_run = 0; 56 | 57 | for (x, y) in x.into_iter().zip(y.into_iter()) { 58 | if x == y { 59 | current_run += 1; 60 | 61 | if current_run > longest_run { 62 | longest_run = current_run; 63 | } 64 | } else { 65 | current_run = 0; 66 | } 67 | } 68 | 69 | longest_run 70 | } 71 | -------------------------------------------------------------------------------- /lec07/src/point.rs: -------------------------------------------------------------------------------- 1 | // #![warn(missing_docs)] 2 | 3 | //! Here is some more documentation!! 4 | //! 5 | //! Wow there's so much! 6 | //! 7 | //! I suggest you try out the [Point] struct -- it's so cool! 8 | 9 | use std::{mem::swap, vec::Vec}; 10 | 11 | 12 | 13 | 14 | /// This struct holds a coordinate pair of `i32`s. 15 | /// 16 | /// It's such a cool struct ur gonna love it! 17 | /// 18 | /// # This is a header! 19 | /// 20 | /// ``` 21 | /// // this is some code 22 | /// let x = 42; 23 | /// ``` 24 | /// 25 | /// Try out the [Point::new] function! 26 | /// 27 | /// Here is some **bold text** and here's some *italics*. 28 | #[derive(Debug, PartialEq)] 29 | pub struct Point { 30 | /// This is the `x` field! So cool! 31 | pub x: i32, 32 | 33 | /// And the `y` field, awesome too 34 | pub y: i32, 35 | } 36 | 37 | impl Point { 38 | pub fn new(x: i32, y: i32) -> Self { 39 | Self { x, y } 40 | } 41 | 42 | 43 | fn hello(&self) { 44 | println!("hello from {} {}", self.x, self.y); 45 | } 46 | 47 | /// This is the add function, bla bla bla 48 | /// 49 | /// ``` 50 | /// # use my_library::point::Point; 51 | /// # 52 | /// let point1 = Point { x: 2, y: 3 }; 53 | /// let point2 = Point { x: 3, y: 2 }; 54 | /// 55 | /// let expected = Point { x: 5, y: 5 }; 56 | /// let result = point1.add(point2); 57 | /// 58 | /// assert_eq!(result, expected); 59 | /// ``` 60 | pub fn add(&self, other: Point) -> Point { 61 | let v: Vec<()> = Vec::new(); 62 | let v: Vec<()> = std::vec::Vec::new(); 63 | 64 | crate::add(Point { x: 4, y: 2 }); 65 | 66 | Self { x: self.x + other.x, y: self.y + other.y } 67 | } 68 | } 69 | 70 | #[cfg(test)] 71 | mod tests { 72 | use super::*; 73 | 74 | #[test] 75 | fn test_add_1() { 76 | let point1 = Point { x: 2, y: 3 }; 77 | let point2 = Point { x: 3, y: 2 }; 78 | 79 | let expected = Point { x: 5, y: 5 }; 80 | let result = point1.add(point2); 81 | 82 | assert_eq!(result, expected); 83 | } 84 | 85 | #[test] 86 | fn test_add_2() { 87 | 88 | } 89 | 90 | #[test] 91 | fn test_add_3() { 92 | 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lec14/thread_sum.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | struct job { 7 | long start, finish; 8 | unsigned long sum; 9 | }; 10 | 11 | void *run_thread(void *argument) { 12 | struct job *j = argument; 13 | long start = j->start; 14 | long finish = j->finish; 15 | unsigned long sum = 0; 16 | 17 | for (long i = start; i < finish; i++) { 18 | sum += i; 19 | } 20 | 21 | j->sum = sum; 22 | 23 | printf("Thread summing integers %10lu to %11lu finished sum is %lu\n", 24 | start, finish, sum); 25 | return NULL; 26 | } 27 | 28 | int main(int argc, char *argv[]) { 29 | if (argc != 3) { 30 | fprintf(stderr, "Usage: %s \n", argv[0]); 31 | return 1; 32 | } 33 | 34 | int n_threads = strtol(argv[1], NULL, 0); 35 | assert(0 < n_threads && n_threads < 1000); 36 | unsigned long integers_to_sum = strtol(argv[2], NULL, 0); 37 | assert(0 < integers_to_sum); 38 | 39 | unsigned long integers_per_thread = (integers_to_sum - 1) / n_threads + 1; 40 | 41 | printf("Creating %d threads to sum the first %lu integers\n" 42 | "Each thread will sum %lu integers\n", 43 | n_threads, integers_to_sum, integers_per_thread); 44 | 45 | pthread_t thread_id[n_threads]; 46 | struct job jobs[n_threads]; 47 | 48 | for (int i = 0; i < n_threads; i++) { 49 | jobs[i].start = i * integers_per_thread; 50 | jobs[i].finish = jobs[i].start + integers_per_thread; 51 | 52 | if (jobs[i].finish > integers_to_sum) { 53 | jobs[i].finish = integers_to_sum; 54 | } 55 | 56 | // create a thread which will sum integers_per_thread integers 57 | pthread_create(&thread_id[i], NULL, run_thread, &jobs[i]); 58 | } 59 | 60 | // Wait for threads to finish, then add results for an overall sum. 61 | unsigned long overall_sum = 0; 62 | for (int i = 0; i < n_threads; i++) { 63 | pthread_join(thread_id[i], NULL); 64 | overall_sum += jobs[i].sum; 65 | } 66 | 67 | printf("\nCombined sum of integers 0 to %lu is %lu\n", integers_to_sum, overall_sum); 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /lec02/playing_around/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | struct Card { 4 | rank: Rank, 5 | suit: Suit, 6 | } 7 | 8 | enum Rank { 9 | FaceRank(FaceRank), 10 | Number(i32), 11 | } 12 | 13 | enum FaceRank { 14 | Ace, 15 | Jack, 16 | Queen, 17 | King, 18 | } 19 | 20 | #[derive(Clone, Copy)] 21 | enum Suit { 22 | Clubs, 23 | Hearts, 24 | Diamonds, 25 | Spades, 26 | } 27 | 28 | #[derive(Clone, Copy)] 29 | struct Foo { 30 | x: i32, 31 | y: bool, 32 | z: char, 33 | a: [char; 10], 34 | } 35 | 36 | #[derive(Clone, Copy)] 37 | struct Bar { 38 | foo: Foo, 39 | } 40 | 41 | fn print_string(string: String) -> String { 42 | println!("{string}"); 43 | string 44 | } 45 | 46 | fn print_string2(string: String) { 47 | println!("{string}"); 48 | } 49 | 50 | fn main() { 51 | let string1 = String::from("hello"); 52 | let string1 = print_string(string1); 53 | println!("{string1}"); 54 | 55 | let string1 = String::from("hello"); 56 | print_string(string1.clone()); 57 | println!("{string1}"); 58 | 59 | // i32, u32, i64, u64, i16, u16, i8, u8, i128, u128, f32, f64, char, bool 60 | // 'x', 61 | // true, false 62 | 63 | let suit = Suit::Clubs; 64 | 65 | let card = Card { 66 | rank: Rank::Number(3), 67 | suit, 68 | }; 69 | 70 | let colour = match suit { 71 | Suit::Clubs | Suit::Spades => "black", 72 | Suit::Hearts | Suit::Diamonds => "red", 73 | }; 74 | 75 | 76 | // Rank::FaceRank { rank } <=> Rank::FaceRank { rank: FaceRank::Ace }, 77 | // rank = FaceRank::Ace 78 | // 79 | // Rank::FaceRank(rank) <=> Rank::FaceRank(FaceRank::Ace), 80 | // rank = FaceRank::Ace 81 | // 82 | // x + 3 = 42 * 2 83 | // x = 81 84 | // 85 | // (x, y) = (12, 50) 86 | // let (x, y) = (12, 50); 87 | 88 | let rank_name = match card.rank { 89 | Rank::FaceRank(rank) => { 90 | match rank { 91 | FaceRank::Ace => "A", 92 | FaceRank::Jack => "J", 93 | FaceRank::Queen => "Q", 94 | FaceRank::King => "K", 95 | }.to_string() 96 | } 97 | Rank::Number(rank) => rank.to_string(), 98 | }; 99 | 100 | let suit_name = match card.suit { 101 | Suit::Clubs => '♣', 102 | Suit::Hearts => '♥', 103 | Suit::Diamonds => '♦', 104 | Suit::Spades => '♠', 105 | }; 106 | 107 | println!("{rank_name}{suit_name}"); 108 | } 109 | -------------------------------------------------------------------------------- /lec11/yew-demo/README.md: -------------------------------------------------------------------------------- 1 | # Yew Trunk Template 2 | 3 | This is a fairly minimal template for a Yew app that's built with [Trunk]. 4 | 5 | ## Usage 6 | 7 | For a more thorough explanation of Trunk and its features, please head over to the [repository][trunk]. 8 | 9 | ### Installation 10 | 11 | If you don't already have it installed, it's time to install Rust: . 12 | The rest of this guide assumes a typical Rust installation which contains both `rustup` and Cargo. 13 | 14 | To compile Rust to WASM, we need to have the `wasm32-unknown-unknown` target installed. 15 | If you don't already have it, install it with the following command: 16 | 17 | ```bash 18 | rustup target add wasm32-unknown-unknown 19 | ``` 20 | 21 | Now that we have our basics covered, it's time to install the star of the show: [Trunk]. 22 | Simply run the following command to install it: 23 | 24 | ```bash 25 | cargo install trunk wasm-bindgen-cli 26 | ``` 27 | 28 | That's it, we're done! 29 | 30 | ### Running 31 | 32 | ```bash 33 | trunk serve 34 | ``` 35 | 36 | Rebuilds the app whenever a change is detected and runs a local server to host it. 37 | 38 | There's also the `trunk watch` command which does the same thing but without hosting it. 39 | 40 | ### Release 41 | 42 | ```bash 43 | trunk build --release 44 | ``` 45 | 46 | This builds the app in release mode similar to `cargo build --release`. 47 | You can also pass the `--release` flag to `trunk serve` if you need to get every last drop of performance. 48 | 49 | Unless overwritten, the output will be located in the `dist` directory. 50 | 51 | ## Using this template 52 | 53 | There are a few things you have to adjust when adopting this template. 54 | 55 | ### Remove example code 56 | 57 | The code in [src/main.rs](src/main.rs) specific to the example is limited to only the `view` method. 58 | There is, however, a fair bit of Sass in [index.scss](index.scss) you can remove. 59 | 60 | ### Update metadata 61 | 62 | Update the `version`, `description` and `repository` fields in the [Cargo.toml](Cargo.toml) file. 63 | The [index.html](index.html) file also contains a `` tag that needs updating. 64 | 65 | 66 | Finally, you should update this very `README` file to be about your app. 67 | 68 | ### License 69 | 70 | The template ships with both the Apache and MIT license. 71 | If you don't want to have your app dual licensed, just remove one (or both) of the files and update the `license` field in `Cargo.toml`. 72 | 73 | There are two empty spaces in the MIT license you need to fill out: `` and `Zac Kologlu <zac.kologlu@gmail.com>`. 74 | 75 | [trunk]: https://github.com/thedodd/trunk -------------------------------------------------------------------------------- /lec09/notes.md: -------------------------------------------------------------------------------- 1 | # Week 5 Lecture Notes 2 | 3 | - Polymorphism, why? 4 | - Generic type parameters (parametric polymorphism) 5 | - Monomorphisation 6 | - Traits (ad-hoc polymorphism) 7 | - Static vs. Dynamic Dispatch 8 | 9 | ## 1. Making Functions Generic 10 | 11 | - Look at smallest_* functions, understand why they're not great 12 | - Compare to (older) Go, C, Python and Rust in how they deal with the problem of functions for many types. 13 | - Write a `smallest` function in Rust 14 | - Compare C++ and Rust's approach to types 15 | - Understand some syntactical Rust specifics 16 | - Use the "turbofish" syntax, and where it commonly occurs. 17 | - Use the `where` syntax, as well as the more concise `<T: Type>` syntax 18 | - Apply multiple bounds to a single type 19 | - Briefly discuss Hindley Milner type systems 20 | 21 | ## 2. Discuss Caveats of "smallness" 22 | 23 | - Have an existential crisis over what "small" is 24 | - Briefly discuss Ordering, Equality, and how Rust approaches them 25 | 26 | ## 3. Sequences 27 | 28 | - Understand approaches to generalise to any number of values 29 | - Explore the possible edge cases with "any number of values" and approaches to fix this. 30 | - Understand and use the Option type to deal with edge cases of comparison. 31 | - Discuss types as constraints, and types as arguments 32 | - How to make a function operating on a sequence more generic 33 | - Syntax in Rust 34 | - Briefly discuss APIT, RPIT 35 | 36 | ## 4. Monomorphisation and Dynamic Dispatch 37 | 38 | - Understand what Monomorphisation is. 39 | - Understand what Dynamic Dispatch is. 40 | - Discuss tradeoffs between the two 41 | 42 | 43 | ## 5. Interesting Traits 44 | 45 | We'll review all of these traits: 46 | 47 | - PartialEq / Eq 48 | - PartialOrd / Ord 49 | - Default 50 | - Copy, Clone 51 | - Debug, Display 52 | - ToString 53 | - Add / AddAssign 54 | - Associated Type vs. Parameters 55 | - Default Types 56 | - BitAdd / BitAddAssign 57 | - From, Into, TryFrom, TryInto 58 | - FromStr, AsRef (AsMut), Borrow (BorrowMut), ToOwned 59 | - Error 60 | - Iterator, FromIterator, IntoIterator 61 | - Discuss how derive macros work 62 | 63 | ## 6. Building Our Own Iterator 64 | - How to implement a Fibonacci Iterator 65 | - Why distinguish between "Iterator" and "IntoIterator" 66 | - How to implement an iterator for arrays 67 | 68 | ## 7. Trait Objects 69 | - Understand what trait objects are, how they work 70 | - Identify that Traits must be in scope to use them 71 | - Discuss the Trait Object Rules 72 | - Discuss the Self: Sized constraint 73 | - Constrast Traits with OOP 74 | 75 | 76 | ## Extra Content 77 | 78 | - The Orphan Rule 79 | - Variadic Functions and Rust 80 | - Using Types at Runtime 81 | - Specialisation 82 | -------------------------------------------------------------------------------- /lec17/exam_q2_24T3/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | /// This function correctly implements finding a string in a list of strings. 4 | /// You do not need to change this function at all, and can assume it behaves correctly. 5 | /// 6 | /// If the string `s` exists in the list, it returns a reference to the first matching string in the list. 7 | /// If the string `s` does not exist in the list, it returns None. 8 | fn find_str_correct<'a, 'b, 'c>(l: &'a Vec<&'b str>, s: &'c str) -> Option<&'b str> { 9 | for x in l.iter() { 10 | if *x == s { 11 | return Some(x); 12 | } 13 | } 14 | 15 | None 16 | } 17 | 18 | /// By default, we will use this function. This function has the correct lifetimes. 19 | #[cfg(not(feature = "find_str_bad_lifetimes"))] 20 | pub fn find_str<'a, 'b, 'c>(l: &'a Vec<&'b str>, s: &'c str) -> Option<&'b str> { 21 | find_str_correct(l, s) 22 | } 23 | 24 | /// If you compile with `cargo build --feature find_str_bad_lifetimes`, this function will be used instead. 25 | /// This function has incorrect lifetimes, and your job is to ensure that when your code calls this function, 26 | /// it does not compile. 27 | #[cfg(feature = "find_str_bad_lifetimes")] 28 | pub fn find_str<'a, 'b>(l: &'a Vec<&'b str>, s: &'b str) -> Option<&'b str> { 29 | find_str_correct(l, s) 30 | } 31 | 32 | /// This function correctly implements finding the most common string in a list of strings. 33 | /// You do not need to change this function at all, and can assume it behaves correctly. 34 | /// 35 | /// It will return the most common string in the list, or None if the list is empty. 36 | /// If there are multiple strings that are equally common, it will return the first one it encounters. 37 | fn most_common_correct<'a, 'b>(l: &'a Vec<&'b str>) -> Option<&'b str> { 38 | let mut counts = HashMap::new(); 39 | for x in l.iter() { 40 | *counts.entry(x).or_insert(0) += 1; 41 | } 42 | 43 | let mut max_count = 0; 44 | let mut max_str = None; 45 | for (s, count) in counts { 46 | if count > max_count { 47 | max_count = count; 48 | max_str = Some(*s); 49 | } 50 | } 51 | 52 | max_str 53 | } 54 | 55 | /// By default, we will use this function. This function has the correct lifetimes. 56 | #[cfg(not(feature = "most_common_bad_lifetimes"))] 57 | pub fn most_common<'a, 'b>(l: &'a Vec<&'b str>) -> Option<&'b str> { 58 | most_common_correct(l) 59 | } 60 | 61 | /// If you compile with `cargo build --feature most_common_bad_lifetimes`, this function will be used instead. 62 | /// This function has incorrect lifetimes, and your job is to ensure that when your code calls this function, 63 | /// it does not compile. 64 | #[cfg(feature = "most_common_bad_lifetimes")] 65 | pub fn most_common<'a, 'b>(l: &'b Vec<&'b str>) -> Option<&'b str> { 66 | most_common_correct(l) 67 | } 68 | -------------------------------------------------------------------------------- /lec12/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | use std::{thread, time::{Duration, Instant}}; 4 | 5 | fn main() { 6 | let mut factor = 2.5; 7 | let result = [1, 2, 3].into_iter() 8 | .map(|x| { 9 | let factor = &mut factor; 10 | 11 | let res = x as f64 * *factor; 12 | *factor += 1.0; 13 | res 14 | }) 15 | .collect::<Vec<_>>(); 16 | 17 | println!("{factor} {result:?}"); 18 | 19 | time_function(|| { 20 | thread::sleep(Duration::from_secs(3)); 21 | 22 | let mut factor = 2.5; 23 | let closure = |x: i32| { 24 | let factor = &mut factor; 25 | 26 | let res = x as f64 * *factor; 27 | *factor += 1.0; 28 | res 29 | }; 30 | 31 | let result = my_map( 32 | [1, 2, 3].into_iter(), 33 | closure, 34 | ) 35 | .collect::<Vec<_>>(); 36 | 37 | println!("{result:?}"); 38 | }); 39 | } 40 | 41 | fn time_function<F>(f: F) 42 | where 43 | F: FnOnce(), 44 | { 45 | let before = Instant::now(); 46 | f(); 47 | let after = Instant::now(); 48 | 49 | let duration = after.duration_since(before); 50 | println!("Function took {duration:?}"); 51 | } 52 | 53 | struct MyMap<I, F> { 54 | iter: I, 55 | f: F, 56 | } 57 | 58 | fn my_map<I, F>(iter: I, f: F) -> MyMap<I, F> { 59 | MyMap { iter, f } 60 | } 61 | 62 | impl<I, F, CurrItem, NewItem> Iterator for MyMap<I, F> 63 | where 64 | I: Iterator<Item = CurrItem>, 65 | F: FnMut(CurrItem) -> NewItem, 66 | { 67 | type Item = NewItem; 68 | 69 | fn next(&mut self) -> Option<Self::Item> { 70 | let curr = self.iter.next()?; 71 | let new = (self.f)(curr); 72 | 73 | Some(new) 74 | } 75 | } 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | // fn mult(x: i32) -> f64 { 88 | // x as f64 * 2.5 89 | // } 90 | 91 | 92 | 93 | 94 | /* 95 | let f: fn(i32, i32) -> i32 = add; 96 | let x: i32 = f(2, 3); 97 | let y: i32 = f(3, 4); 98 | 99 | println!("{x} {y}"); 100 | 101 | let my_closure = || { 102 | println!("hello!"); 103 | }; 104 | my_closure(); 105 | 106 | let closure_add = |x: i32, y: i32| x + y; 107 | 108 | // print_hello(); 109 | call_n(my_closure, 2); 110 | } 111 | 112 | fn add(x: i32, y: i32) -> i32 { 113 | x + y 114 | } 115 | 116 | fn compose<A, B, C>(f: fn(A) -> B, g: fn(B) -> C, a: A) -> C { 117 | let b = f(a); 118 | let c = g(b); 119 | 120 | c 121 | } 122 | 123 | fn call_n(f: fn(), n: usize) { 124 | for _ in 0..n { 125 | f(); 126 | } 127 | } 128 | 129 | fn print_hello() { 130 | println!("hello!"); 131 | } 132 | 133 | 134 | let a = 42; 135 | let b = 3.14; 136 | let c = 'z'; 137 | let d = String::from("hello"); 138 | 139 | let f: fn(i32) -> i32 = |x| { 140 | println!("{a} {b} {c} {d}"); 141 | x * 2 142 | }; 143 | let g: fn(i32) -> i32 = |x| { 144 | println!("{a}"); 145 | x + 5 146 | }; // <--------. 147 | // 0x81273981723 the location of the code -| 148 | 149 | 150 | let mut f: fn(i32) -> i32 = |x| x * 2; 151 | f = |x| x + 5; 152 | 153 | 154 | 155 | 156 | */ 157 | -------------------------------------------------------------------------------- /lec16/vec-insane/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | use my_vec::MyVec; 4 | 5 | mod my_vec { 6 | use std::{alloc::{self, Layout}, ptr::{self, drop_in_place}}; 7 | 8 | pub struct MyVec<T> { 9 | buf: *mut T, 10 | len: usize, 11 | cap: usize, 12 | } 13 | 14 | impl<T> MyVec<T> { 15 | const INITIAL_CAPACITY: usize = 4; 16 | 17 | pub fn new() -> Self { 18 | // This check is relied upon by unsafe code elsewhere 19 | let size = std::mem::size_of::<T>(); 20 | if size == 0 { 21 | panic!("ZSTs are not supported"); 22 | } 23 | 24 | Self { 25 | buf: ptr::null_mut(), 26 | len: 0, 27 | cap: 0, 28 | } 29 | } 30 | 31 | pub fn push(&mut self, value: T) { 32 | if self.len == self.cap { 33 | self.expand_capacity(); 34 | } 35 | 36 | // self.buf is valid! 37 | // self.len < self.cap 38 | let first_ptr = self.buf; 39 | let push_ptr = first_ptr.wrapping_add(self.len); 40 | 41 | // SAFETY: 42 | // This is a valid location to store a value! 43 | unsafe { push_ptr.write(value); } 44 | self.len += 1; 45 | } 46 | 47 | pub fn pop(&mut self) -> Option<T> { 48 | if self.len == 0 { 49 | return None; 50 | } 51 | 52 | let first_ptr = self.buf; 53 | let last_ptr = first_ptr.wrapping_add(self.len - 1); 54 | 55 | // SAFETY: 56 | // This is a valid location to read a value from! 57 | let value = unsafe { last_ptr.read() }; 58 | self.len -= 1; 59 | 60 | Some(value) 61 | } 62 | 63 | fn expand_capacity(&mut self) { 64 | if self.buf.is_null() { 65 | // make an initial allocation 66 | // self.buf = malloc(sizeof(T) * INITIAL_CAPACITY); 67 | let layout = Layout::array::<T>(Self::INITIAL_CAPACITY) 68 | .expect("the allocation is too big"); 69 | 70 | // SAFETY: 71 | // > layout must have non-zero size. 72 | // > Attempting to allocate for a zero-sized 73 | // > layout may result in undefined behavior. 74 | // 75 | // The Layout can only be zero sized if T is ZST, 76 | // and that is rejected in Self::new with a panic. 77 | self.buf = unsafe { alloc::alloc(layout) } as _; 78 | self.cap = Self::INITIAL_CAPACITY; 79 | } else { 80 | // expand the existing allocation 81 | let old_cap = self.cap; 82 | let new_cap = 2 * old_cap; 83 | 84 | let old_layout = Layout::array::<T>(old_cap) 85 | .expect("the allocation is too big"); 86 | let new_layout = Layout::array::<T>(new_cap) 87 | .expect("the allocation is too big"); 88 | 89 | // SAFETY: 90 | // > ptr is allocated via this allocator, 91 | // => the ptr came from a previous alloc::alloc or alloc::realloc, so this is true! 92 | // > layout is the same layout that was used to allocate that block of memory, 93 | // => we use the existing capacity which is tied to the last allocation, so this is true! 94 | // > new_size is greater than zero. 95 | // => See note above about Layout ZST 96 | // > new_size, when rounded up to the nearest multiple of layout.align(), does not overflow isize (i.e., the rounded value must be less than or equal to isize::MAX). 97 | // => pretty sure! 98 | self.buf = unsafe { alloc::realloc(self.buf as _, old_layout, new_layout.size()) } as _; 99 | self.cap = new_cap; 100 | } 101 | } 102 | } 103 | 104 | impl<T> Drop for MyVec<T> { 105 | fn drop(&mut self) { 106 | if self.buf.is_null() { 107 | return; 108 | } 109 | 110 | for index in 0..self.len { 111 | let ptr = self.buf.wrapping_add(index); 112 | // SAFETY: bla bla bla 113 | unsafe { drop_in_place(ptr) }; 114 | } 115 | 116 | let layout = Layout::array::<T>(self.cap) 117 | .expect("the allocation is too big"); 118 | // SAFETY: bla bla bla 119 | unsafe { alloc::dealloc(self.buf as _, layout) }; 120 | } 121 | } 122 | } 123 | 124 | fn main() { 125 | let mut my_vec = MyVec::new(); 126 | my_vec.push(String::from("1")); 127 | my_vec.push(String::from("2")); 128 | my_vec.push(String::from("3")); 129 | // dbg!(my_vec.pop()); 130 | // dbg!(my_vec.pop()); 131 | // dbg!(my_vec.pop()); 132 | dbg!(my_vec.pop()); 133 | } 134 | -------------------------------------------------------------------------------- /lec13/rust-race/src/data_race.rs: -------------------------------------------------------------------------------- 1 | use std::thread::JoinHandle; 2 | 3 | const N_THREADS: usize = 50; 4 | const N_INCREMENTS: usize = 100000; 5 | 6 | #[cfg(any())] 7 | pub mod attempt1 { 8 | use std::array; 9 | 10 | use super::*; 11 | 12 | static mut MY_NUMBER: u64 = 0; 13 | 14 | fn thread() { 15 | for _ in 0..N_INCREMENTS { 16 | MY_NUMBER += 1; 17 | } 18 | } 19 | 20 | pub fn main() { 21 | let mut threads = [const { None }; N_THREADS]; 22 | 23 | for i in 0..N_THREADS { 24 | threads[i] = Some(std::thread::spawn(thread)); 25 | } 26 | for i in 0..N_THREADS { 27 | threads[i].take().unwrap().join(); 28 | } 29 | 30 | println!("Final total: {MY_NUMBER} (expected {})\n", N_THREADS * N_INCREMENTS); 31 | } 32 | } 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | #[cfg(all())] 47 | pub mod attempt2 { 48 | use std::{array, rc::Rc, sync::Arc, thread}; 49 | 50 | use super::*; 51 | 52 | fn thread(my_number: &mut u64) { 53 | for _ in 0..N_INCREMENTS { 54 | *my_number += 1; 55 | } 56 | } 57 | 58 | pub fn main() { 59 | let mut my_number = 0; 60 | 61 | thread::scope(|scope| { 62 | for _ in 0..N_THREADS { 63 | scope.spawn(|| { 64 | thread(&mut my_number); 65 | }); 66 | } 67 | }); 68 | 69 | println!("Final total: {my_number} (expected {})\n", N_THREADS * N_INCREMENTS); 70 | } 71 | } 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | #[cfg(any())] 86 | pub mod attempt3 { 87 | use std::{array, cell::Cell, thread}; 88 | 89 | use super::*; 90 | 91 | fn thread(my_number: &Cell<u64>) { 92 | for _ in 0..N_INCREMENTS { 93 | my_number.set(my_number.get() + 1); 94 | } 95 | } 96 | 97 | pub fn main() { 98 | let my_number = Cell::new(0); 99 | 100 | thread::scope(|scope| { 101 | for _ in 0..N_THREADS { 102 | scope.spawn(|| { 103 | thread(&my_number); 104 | }); 105 | } 106 | }); 107 | 108 | println!("Final total: {} (expected {})\n", my_number.get(), N_THREADS * N_INCREMENTS); 109 | } 110 | } 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | #[cfg(any())] 125 | pub mod attempt4 { 126 | use std::{thread, array, cell::Cell, sync::{atomic::{AtomicU64, Ordering}, Mutex}}; 127 | 128 | use super::*; 129 | 130 | fn thread(my_number: &Mutex<u64>) { 131 | for _ in 0..N_INCREMENTS { 132 | *my_number.lock().unwrap() += 1; 133 | } 134 | } 135 | 136 | pub fn main() { 137 | let my_number: Mutex<u64> = Mutex::new(0); 138 | let mut threads = [const { None }; N_THREADS]; 139 | 140 | for i in 0..N_THREADS { 141 | threads[i] = Some(std::thread::spawn(|| thread(&my_number))); 142 | } 143 | for i in 0..N_THREADS { 144 | threads[i].take().unwrap().join(); 145 | } 146 | 147 | println!("Final total: {} (expected {})\n", *my_number.lock().unwrap(), N_THREADS * N_INCREMENTS); 148 | } 149 | } 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | #[cfg(any())] 164 | pub mod attempt4fix1 { 165 | use std::{array, cell::Cell, sync::{atomic::{AtomicU64, Ordering}, Mutex, Arc}}; 166 | 167 | use super::*; 168 | 169 | fn thread(my_number: Arc<Mutex<u64>>) { 170 | for _ in 0..N_INCREMENTS { 171 | *my_number.lock().unwrap() += 1; 172 | } 173 | } 174 | 175 | pub fn main() { 176 | let my_number: Arc<Mutex<u64>> = Arc::new(Mutex::new(0)); 177 | let mut threads = [const { None }; N_THREADS]; 178 | 179 | for i in 0..N_THREADS { 180 | let my_number = my_number.clone(); 181 | threads[i] = Some(std::thread::spawn(|| thread(my_number))); 182 | } 183 | for i in 0..N_THREADS { 184 | threads[i].take().unwrap().join(); 185 | } 186 | 187 | println!("Final total: {} (expected {})\n", *my_number.lock().unwrap(), N_THREADS * N_INCREMENTS); 188 | } 189 | } 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | #[cfg(any())] 204 | pub mod attempt4fix2 { 205 | use std::{array, cell::Cell, sync::{atomic::{AtomicU64, Ordering}, Arc, Mutex}, thread::{self, sleep}, time::Duration}; 206 | 207 | use super::*; 208 | 209 | fn thread(my_number: &Mutex<u64>) { 210 | for _ in 0..N_INCREMENTS { 211 | let mut guard = my_number.lock().unwrap(); 212 | *guard += 1; 213 | } 214 | } 215 | 216 | pub fn main() { 217 | let my_number: Mutex<u64> = Mutex::new(0); 218 | 219 | thread::scope(|scope| { 220 | for i in 0..N_THREADS { 221 | scope.spawn(|| thread(&my_number)); 222 | } 223 | }); 224 | 225 | println!("Final total: {} (expected {})\n", *my_number.lock().unwrap(), N_THREADS * N_INCREMENTS); 226 | } 227 | } 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | #[cfg(any())] 242 | pub mod attempt5 { 243 | use std::{array, cell::Cell, sync::atomic::{AtomicU64, Ordering}}; 244 | 245 | use super::*; 246 | 247 | static MY_NUMBER: AtomicU64 = AtomicU64::new(0); 248 | 249 | fn thread() { 250 | for _ in 0..N_INCREMENTS { 251 | MY_NUMBER.fetch_add(1, Ordering::SeqCst); 252 | } 253 | } 254 | 255 | pub fn main() { 256 | let mut threads = [const { None }; N_THREADS]; 257 | 258 | for i in 0..N_THREADS { 259 | threads[i] = Some(std::thread::spawn(thread)); 260 | } 261 | for i in 0..N_THREADS { 262 | threads[i].take().unwrap().join(); 263 | } 264 | 265 | println!("Final total: {} (expected {})\n", MY_NUMBER.load(Ordering::SeqCst), N_THREADS * N_INCREMENTS); 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /lec09/polymorphism/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | use std::{ 4 | fmt::{Debug, Display, Error, Formatter}, 5 | ops::{Add, Mul}, 6 | thread::current, 7 | }; 8 | 9 | pub fn main() { 10 | dbg!(smallest(3, 2)); 11 | dbg!(smallest('a', 'b')); 12 | dbg!(smallest(3.5, 3.7)); 13 | let my_vec: Vec<i32> = vec![]; 14 | dbg!(smallest_from_vec(my_vec)); 15 | 16 | // default_testing(); 17 | 18 | let vec = vec![1, 2, 3]; 19 | let iter = vec.into_iter(); 20 | 21 | // test_fibonacci(); 22 | test_iterator(); 23 | } 24 | 25 | // fn odd_integers(start: u32, stop: u32) -> impl Iterator<Item = u32> { 26 | // if start == 0 { 27 | // (start..stop).filter(|i| i % 2 != 0).map(|x| x * 1) 28 | // } else { 29 | // (start..stop).map(|x| x * 2) 30 | // } 31 | // } 32 | enum MyInputs { 33 | String(String), 34 | Num(i32), 35 | } 36 | 37 | // enum Option<T> { 38 | // Some(T), 39 | // None, 40 | // } 41 | 42 | // void qsort(void* array, size_t size, int(void*, void*) cmp); 43 | 44 | fn qsort<I>(iter: impl IntoIterator<Item = I>) -> Vec<I> 45 | where 46 | I: PartialOrd, 47 | { 48 | todo!() 49 | } 50 | 51 | fn smallest_from_vec<T>(v: impl IntoIterator<Item = T>) -> Option<T> 52 | where 53 | T: PartialOrd + Debug, 54 | { 55 | let mut iter = v.into_iter(); 56 | let mut lowest = iter.next()?; 57 | 58 | for value in iter { 59 | if value < lowest { 60 | lowest = value; 61 | } 62 | } 63 | 64 | return Some(lowest); 65 | } 66 | 67 | fn smallest<T>(x: T, y: T) -> T 68 | where 69 | T: PartialOrd + std::fmt::Debug, 70 | { 71 | if x < y { 72 | x 73 | } else { 74 | y 75 | } 76 | } 77 | 78 | // #[derive()] 79 | 80 | #[derive(Default, Clone, Copy)] 81 | struct Coordinate { 82 | x: i32, 83 | y: i32, 84 | } 85 | 86 | struct Coordinate3d { 87 | x: i32, 88 | y: i32, 89 | z: i32, 90 | } 91 | 92 | impl From<Coordinate> for Coordinate3d { 93 | fn from(value: Coordinate) -> Self { 94 | Coordinate3d { 95 | x: value.x, 96 | y: value.y, 97 | z: 0, 98 | } 99 | } 100 | } 101 | 102 | /*impl Into<Coordinate3d> for Coordinate { 103 | fn into(self) -> Coordinate3d { 104 | Coordinate3d { 105 | x: self.x, 106 | y: self.y, 107 | z: 0, 108 | } 109 | } 110 | }*/ 111 | /* 112 | impl<T: From<U>, U> Into<T> for U { 113 | fn into(self) -> T { 114 | T::from(self) 115 | } 116 | }*/ 117 | 118 | impl Display for Coordinate { 119 | fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { 120 | write!(f, "({}, {})", self.x, self.y) 121 | } 122 | } 123 | 124 | impl Add for Coordinate { 125 | type Output = Coordinate; 126 | 127 | fn add(self, rhs: Coordinate) -> Self::Output { 128 | Coordinate { 129 | x: self.x + rhs.x, 130 | y: self.y + rhs.y, 131 | } 132 | } 133 | } 134 | 135 | impl Mul<i32> for Coordinate { 136 | type Output = Coordinate; 137 | 138 | fn mul(self, rhs: i32) -> Coordinate { 139 | Coordinate { 140 | x: self.x * rhs, 141 | y: self.y * rhs, 142 | } 143 | } 144 | } 145 | 146 | // impl Clone for Coordinate { 147 | // fn clone(self: &Self) -> Self { 148 | // Self { 149 | // x: self.x.clone() 150 | // y: self.y.clone() 151 | // } 152 | // } 153 | // } 154 | 155 | fn default_testing() { 156 | let coord = Coordinate::default(); 157 | 158 | dbg!(coord.to_string()); 159 | dbg!(3.to_string_2()); 160 | 161 | let x = 1 + 2; 162 | } 163 | 164 | trait ToString6991 { 165 | fn to_string_2(&self) -> String; 166 | } 167 | 168 | impl<T: Display> ToString6991 for T { 169 | fn to_string_2(&self) -> String { 170 | self.to_string() 171 | } 172 | } 173 | 174 | // trait Add<T> { 175 | // fn add(self, rhs: T) -> T; 176 | // } 177 | 178 | // impl Add for i32 { 179 | // fn add(self, rhs: i32) -> i32 { 180 | // self + rhs 181 | // } 182 | // } 183 | 184 | trait AddOne { 185 | type Output; 186 | fn adds_one(self) -> Self::Output; 187 | } 188 | 189 | impl AddOne for i32 { 190 | type Output = i32; 191 | 192 | fn adds_one(self) -> Self::Output { 193 | self + 1 194 | } 195 | } 196 | 197 | impl AddOne for &i32 { 198 | type Output = i32; 199 | 200 | fn adds_one(self) -> Self::Output { 201 | (*self) + 1 202 | } 203 | } 204 | 205 | fn is_hello<T: AsRef<str>>(s: T) { 206 | assert_eq!("hello", s.as_ref()); 207 | } 208 | 209 | fn is_hello_(s: &str) { 210 | assert_eq!("hello", s); 211 | } 212 | 213 | struct Fibonacci { 214 | curr: i32, 215 | next: i32, 216 | } 217 | 218 | impl Iterator for Fibonacci { 219 | type Item = i32; 220 | 221 | fn next(&mut self) -> Option<Self::Item> { 222 | let c = self.curr; 223 | let n = self.next; 224 | 225 | self.curr = n; 226 | self.next = c + n; 227 | 228 | if n > 10000000 { 229 | None 230 | } else { 231 | Some(c) 232 | } 233 | } 234 | } 235 | 236 | fn test_fibonacci() { 237 | let mut fib = Fibonacci { curr: 0, next: 1 }; 238 | dbg!(fib.next()); 239 | dbg!(fib.next()); 240 | dbg!(fib.next()); 241 | dbg!(fib.next()); 242 | dbg!(fib.next()); 243 | dbg!(fib.next()); 244 | dbg!(fib.next()); 245 | dbg!(fib.next()); 246 | 247 | dbg!(fib.collect::<Vec<_>>()); 248 | } 249 | 250 | struct VectorIterator<'a, T> { 251 | vec: &'a Vec<T>, 252 | position: usize, 253 | } 254 | 255 | impl<'b, T> Iterator for VectorIterator<'b, T> { 256 | type Item = &'b T; 257 | 258 | fn next(&mut self) -> Option<Self::Item> { 259 | let current_pos = self.position; 260 | self.position += 1; 261 | if current_pos >= self.vec.len() { 262 | None 263 | } else { 264 | Some(&self.vec[current_pos]) 265 | } 266 | } 267 | } 268 | 269 | fn test_iterator() { 270 | let my_vec = vec![1, 2, 3]; 271 | let mut my_vec_iter = VectorIterator { 272 | vec: &my_vec, 273 | position: 0, 274 | }; 275 | 276 | for x in my_vec_iter { 277 | dbg!(x); 278 | } 279 | } 280 | -------------------------------------------------------------------------------- /lec11/yew-demo/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | -------------------------------------------------------------------------------- /lec11/yew-demo/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.24.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler2" 16 | version = "2.0.0" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" 19 | 20 | [[package]] 21 | name = "anymap2" 22 | version = "0.13.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" 25 | 26 | [[package]] 27 | name = "autocfg" 28 | version = "1.4.0" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 31 | 32 | [[package]] 33 | name = "backtrace" 34 | version = "0.3.74" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" 37 | dependencies = [ 38 | "addr2line", 39 | "cfg-if", 40 | "libc", 41 | "miniz_oxide", 42 | "object", 43 | "rustc-demangle", 44 | "windows-targets", 45 | ] 46 | 47 | [[package]] 48 | name = "bincode" 49 | version = "1.3.3" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" 52 | dependencies = [ 53 | "serde", 54 | ] 55 | 56 | [[package]] 57 | name = "boolinator" 58 | version = "2.4.0" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "cfa8873f51c92e232f9bac4065cddef41b714152812bfc5f7672ba16d6ef8cd9" 61 | 62 | [[package]] 63 | name = "bumpalo" 64 | version = "3.17.0" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" 67 | 68 | [[package]] 69 | name = "bytes" 70 | version = "1.10.1" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" 73 | 74 | [[package]] 75 | name = "cfg-if" 76 | version = "1.0.0" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 79 | 80 | [[package]] 81 | name = "console_error_panic_hook" 82 | version = "0.1.7" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" 85 | dependencies = [ 86 | "cfg-if", 87 | "wasm-bindgen", 88 | ] 89 | 90 | [[package]] 91 | name = "equivalent" 92 | version = "1.0.2" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" 95 | 96 | [[package]] 97 | name = "fnv" 98 | version = "1.0.7" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 101 | 102 | [[package]] 103 | name = "form_urlencoded" 104 | version = "1.2.1" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" 107 | dependencies = [ 108 | "percent-encoding", 109 | ] 110 | 111 | [[package]] 112 | name = "futures" 113 | version = "0.3.31" 114 | source = "registry+https://github.com/rust-lang/crates.io-index" 115 | checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" 116 | dependencies = [ 117 | "futures-channel", 118 | "futures-core", 119 | "futures-io", 120 | "futures-sink", 121 | "futures-task", 122 | "futures-util", 123 | ] 124 | 125 | [[package]] 126 | name = "futures-channel" 127 | version = "0.3.31" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" 130 | dependencies = [ 131 | "futures-core", 132 | "futures-sink", 133 | ] 134 | 135 | [[package]] 136 | name = "futures-core" 137 | version = "0.3.31" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" 140 | 141 | [[package]] 142 | name = "futures-io" 143 | version = "0.3.31" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" 146 | 147 | [[package]] 148 | name = "futures-macro" 149 | version = "0.3.31" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" 152 | dependencies = [ 153 | "proc-macro2", 154 | "quote", 155 | "syn 2.0.100", 156 | ] 157 | 158 | [[package]] 159 | name = "futures-sink" 160 | version = "0.3.31" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" 163 | 164 | [[package]] 165 | name = "futures-task" 166 | version = "0.3.31" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" 169 | 170 | [[package]] 171 | name = "futures-util" 172 | version = "0.3.31" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" 175 | dependencies = [ 176 | "futures-channel", 177 | "futures-core", 178 | "futures-io", 179 | "futures-macro", 180 | "futures-sink", 181 | "futures-task", 182 | "memchr", 183 | "pin-project-lite", 184 | "pin-utils", 185 | "slab", 186 | ] 187 | 188 | [[package]] 189 | name = "getrandom" 190 | version = "0.2.15" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" 193 | dependencies = [ 194 | "cfg-if", 195 | "js-sys", 196 | "libc", 197 | "wasi", 198 | "wasm-bindgen", 199 | ] 200 | 201 | [[package]] 202 | name = "gimli" 203 | version = "0.31.1" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" 206 | 207 | [[package]] 208 | name = "gloo" 209 | version = "0.8.1" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "28999cda5ef6916ffd33fb4a7b87e1de633c47c0dc6d97905fee1cdaa142b94d" 212 | dependencies = [ 213 | "gloo-console 0.2.3", 214 | "gloo-dialogs 0.1.1", 215 | "gloo-events 0.1.2", 216 | "gloo-file 0.2.3", 217 | "gloo-history 0.1.5", 218 | "gloo-net 0.3.1", 219 | "gloo-render 0.1.1", 220 | "gloo-storage 0.2.2", 221 | "gloo-timers 0.2.6", 222 | "gloo-utils 0.1.7", 223 | "gloo-worker 0.2.1", 224 | ] 225 | 226 | [[package]] 227 | name = "gloo" 228 | version = "0.10.0" 229 | source = "registry+https://github.com/rust-lang/crates.io-index" 230 | checksum = "cd35526c28cc55c1db77aed6296de58677dbab863b118483a27845631d870249" 231 | dependencies = [ 232 | "gloo-console 0.3.0", 233 | "gloo-dialogs 0.2.0", 234 | "gloo-events 0.2.0", 235 | "gloo-file 0.3.0", 236 | "gloo-history 0.2.2", 237 | "gloo-net 0.4.0", 238 | "gloo-render 0.2.0", 239 | "gloo-storage 0.3.0", 240 | "gloo-timers 0.3.0", 241 | "gloo-utils 0.2.0", 242 | "gloo-worker 0.4.0", 243 | ] 244 | 245 | [[package]] 246 | name = "gloo-console" 247 | version = "0.2.3" 248 | source = "registry+https://github.com/rust-lang/crates.io-index" 249 | checksum = "82b7ce3c05debe147233596904981848862b068862e9ec3e34be446077190d3f" 250 | dependencies = [ 251 | "gloo-utils 0.1.7", 252 | "js-sys", 253 | "serde", 254 | "wasm-bindgen", 255 | "web-sys", 256 | ] 257 | 258 | [[package]] 259 | name = "gloo-console" 260 | version = "0.3.0" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "2a17868f56b4a24f677b17c8cb69958385102fa879418052d60b50bc1727e261" 263 | dependencies = [ 264 | "gloo-utils 0.2.0", 265 | "js-sys", 266 | "serde", 267 | "wasm-bindgen", 268 | "web-sys", 269 | ] 270 | 271 | [[package]] 272 | name = "gloo-dialogs" 273 | version = "0.1.1" 274 | source = "registry+https://github.com/rust-lang/crates.io-index" 275 | checksum = "67062364ac72d27f08445a46cab428188e2e224ec9e37efdba48ae8c289002e6" 276 | dependencies = [ 277 | "wasm-bindgen", 278 | "web-sys", 279 | ] 280 | 281 | [[package]] 282 | name = "gloo-dialogs" 283 | version = "0.2.0" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "bf4748e10122b01435750ff530095b1217cf6546173459448b83913ebe7815df" 286 | dependencies = [ 287 | "wasm-bindgen", 288 | "web-sys", 289 | ] 290 | 291 | [[package]] 292 | name = "gloo-events" 293 | version = "0.1.2" 294 | source = "registry+https://github.com/rust-lang/crates.io-index" 295 | checksum = "68b107f8abed8105e4182de63845afcc7b69c098b7852a813ea7462a320992fc" 296 | dependencies = [ 297 | "wasm-bindgen", 298 | "web-sys", 299 | ] 300 | 301 | [[package]] 302 | name = "gloo-events" 303 | version = "0.2.0" 304 | source = "registry+https://github.com/rust-lang/crates.io-index" 305 | checksum = "27c26fb45f7c385ba980f5fa87ac677e363949e065a083722697ef1b2cc91e41" 306 | dependencies = [ 307 | "wasm-bindgen", 308 | "web-sys", 309 | ] 310 | 311 | [[package]] 312 | name = "gloo-file" 313 | version = "0.2.3" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "a8d5564e570a38b43d78bdc063374a0c3098c4f0d64005b12f9bbe87e869b6d7" 316 | dependencies = [ 317 | "gloo-events 0.1.2", 318 | "js-sys", 319 | "wasm-bindgen", 320 | "web-sys", 321 | ] 322 | 323 | [[package]] 324 | name = "gloo-file" 325 | version = "0.3.0" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "97563d71863fb2824b2e974e754a81d19c4a7ec47b09ced8a0e6656b6d54bd1f" 328 | dependencies = [ 329 | "gloo-events 0.2.0", 330 | "js-sys", 331 | "wasm-bindgen", 332 | "web-sys", 333 | ] 334 | 335 | [[package]] 336 | name = "gloo-history" 337 | version = "0.1.5" 338 | source = "registry+https://github.com/rust-lang/crates.io-index" 339 | checksum = "85725d90bf0ed47063b3930ef28e863658a7905989e9929a8708aab74a1d5e7f" 340 | dependencies = [ 341 | "gloo-events 0.1.2", 342 | "gloo-utils 0.1.7", 343 | "serde", 344 | "serde-wasm-bindgen 0.5.0", 345 | "serde_urlencoded", 346 | "thiserror", 347 | "wasm-bindgen", 348 | "web-sys", 349 | ] 350 | 351 | [[package]] 352 | name = "gloo-history" 353 | version = "0.2.2" 354 | source = "registry+https://github.com/rust-lang/crates.io-index" 355 | checksum = "903f432be5ba34427eac5e16048ef65604a82061fe93789f2212afc73d8617d6" 356 | dependencies = [ 357 | "getrandom", 358 | "gloo-events 0.2.0", 359 | "gloo-utils 0.2.0", 360 | "serde", 361 | "serde-wasm-bindgen 0.6.5", 362 | "serde_urlencoded", 363 | "thiserror", 364 | "wasm-bindgen", 365 | "web-sys", 366 | ] 367 | 368 | [[package]] 369 | name = "gloo-net" 370 | version = "0.3.1" 371 | source = "registry+https://github.com/rust-lang/crates.io-index" 372 | checksum = "a66b4e3c7d9ed8d315fd6b97c8b1f74a7c6ecbbc2320e65ae7ed38b7068cc620" 373 | dependencies = [ 374 | "futures-channel", 375 | "futures-core", 376 | "futures-sink", 377 | "gloo-utils 0.1.7", 378 | "http", 379 | "js-sys", 380 | "pin-project", 381 | "serde", 382 | "serde_json", 383 | "thiserror", 384 | "wasm-bindgen", 385 | "wasm-bindgen-futures", 386 | "web-sys", 387 | ] 388 | 389 | [[package]] 390 | name = "gloo-net" 391 | version = "0.4.0" 392 | source = "registry+https://github.com/rust-lang/crates.io-index" 393 | checksum = "8ac9e8288ae2c632fa9f8657ac70bfe38a1530f345282d7ba66a1f70b72b7dc4" 394 | dependencies = [ 395 | "futures-channel", 396 | "futures-core", 397 | "futures-sink", 398 | "gloo-utils 0.2.0", 399 | "http", 400 | "js-sys", 401 | "pin-project", 402 | "serde", 403 | "serde_json", 404 | "thiserror", 405 | "wasm-bindgen", 406 | "wasm-bindgen-futures", 407 | "web-sys", 408 | ] 409 | 410 | [[package]] 411 | name = "gloo-render" 412 | version = "0.1.1" 413 | source = "registry+https://github.com/rust-lang/crates.io-index" 414 | checksum = "2fd9306aef67cfd4449823aadcd14e3958e0800aa2183955a309112a84ec7764" 415 | dependencies = [ 416 | "wasm-bindgen", 417 | "web-sys", 418 | ] 419 | 420 | [[package]] 421 | name = "gloo-render" 422 | version = "0.2.0" 423 | source = "registry+https://github.com/rust-lang/crates.io-index" 424 | checksum = "56008b6744713a8e8d98ac3dcb7d06543d5662358c9c805b4ce2167ad4649833" 425 | dependencies = [ 426 | "wasm-bindgen", 427 | "web-sys", 428 | ] 429 | 430 | [[package]] 431 | name = "gloo-storage" 432 | version = "0.2.2" 433 | source = "registry+https://github.com/rust-lang/crates.io-index" 434 | checksum = "5d6ab60bf5dbfd6f0ed1f7843da31b41010515c745735c970e821945ca91e480" 435 | dependencies = [ 436 | "gloo-utils 0.1.7", 437 | "js-sys", 438 | "serde", 439 | "serde_json", 440 | "thiserror", 441 | "wasm-bindgen", 442 | "web-sys", 443 | ] 444 | 445 | [[package]] 446 | name = "gloo-storage" 447 | version = "0.3.0" 448 | source = "registry+https://github.com/rust-lang/crates.io-index" 449 | checksum = "fbc8031e8c92758af912f9bc08fbbadd3c6f3cfcbf6b64cdf3d6a81f0139277a" 450 | dependencies = [ 451 | "gloo-utils 0.2.0", 452 | "js-sys", 453 | "serde", 454 | "serde_json", 455 | "thiserror", 456 | "wasm-bindgen", 457 | "web-sys", 458 | ] 459 | 460 | [[package]] 461 | name = "gloo-timers" 462 | version = "0.2.6" 463 | source = "registry+https://github.com/rust-lang/crates.io-index" 464 | checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" 465 | dependencies = [ 466 | "js-sys", 467 | "wasm-bindgen", 468 | ] 469 | 470 | [[package]] 471 | name = "gloo-timers" 472 | version = "0.3.0" 473 | source = "registry+https://github.com/rust-lang/crates.io-index" 474 | checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" 475 | dependencies = [ 476 | "js-sys", 477 | "wasm-bindgen", 478 | ] 479 | 480 | [[package]] 481 | name = "gloo-utils" 482 | version = "0.1.7" 483 | source = "registry+https://github.com/rust-lang/crates.io-index" 484 | checksum = "037fcb07216cb3a30f7292bd0176b050b7b9a052ba830ef7d5d65f6dc64ba58e" 485 | dependencies = [ 486 | "js-sys", 487 | "serde", 488 | "serde_json", 489 | "wasm-bindgen", 490 | "web-sys", 491 | ] 492 | 493 | [[package]] 494 | name = "gloo-utils" 495 | version = "0.2.0" 496 | source = "registry+https://github.com/rust-lang/crates.io-index" 497 | checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" 498 | dependencies = [ 499 | "js-sys", 500 | "serde", 501 | "serde_json", 502 | "wasm-bindgen", 503 | "web-sys", 504 | ] 505 | 506 | [[package]] 507 | name = "gloo-worker" 508 | version = "0.2.1" 509 | source = "registry+https://github.com/rust-lang/crates.io-index" 510 | checksum = "13471584da78061a28306d1359dd0178d8d6fc1c7c80e5e35d27260346e0516a" 511 | dependencies = [ 512 | "anymap2", 513 | "bincode", 514 | "gloo-console 0.2.3", 515 | "gloo-utils 0.1.7", 516 | "js-sys", 517 | "serde", 518 | "wasm-bindgen", 519 | "wasm-bindgen-futures", 520 | "web-sys", 521 | ] 522 | 523 | [[package]] 524 | name = "gloo-worker" 525 | version = "0.4.0" 526 | source = "registry+https://github.com/rust-lang/crates.io-index" 527 | checksum = "76495d3dd87de51da268fa3a593da118ab43eb7f8809e17eb38d3319b424e400" 528 | dependencies = [ 529 | "bincode", 530 | "futures", 531 | "gloo-utils 0.2.0", 532 | "gloo-worker-macros", 533 | "js-sys", 534 | "pinned", 535 | "serde", 536 | "thiserror", 537 | "wasm-bindgen", 538 | "wasm-bindgen-futures", 539 | "web-sys", 540 | ] 541 | 542 | [[package]] 543 | name = "gloo-worker-macros" 544 | version = "0.1.0" 545 | source = "registry+https://github.com/rust-lang/crates.io-index" 546 | checksum = "956caa58d4857bc9941749d55e4bd3000032d8212762586fa5705632967140e7" 547 | dependencies = [ 548 | "proc-macro-crate", 549 | "proc-macro2", 550 | "quote", 551 | "syn 2.0.100", 552 | ] 553 | 554 | [[package]] 555 | name = "hashbrown" 556 | version = "0.15.2" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" 559 | 560 | [[package]] 561 | name = "hermit-abi" 562 | version = "0.3.9" 563 | source = "registry+https://github.com/rust-lang/crates.io-index" 564 | checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" 565 | 566 | [[package]] 567 | name = "http" 568 | version = "0.2.12" 569 | source = "registry+https://github.com/rust-lang/crates.io-index" 570 | checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" 571 | dependencies = [ 572 | "bytes", 573 | "fnv", 574 | "itoa", 575 | ] 576 | 577 | [[package]] 578 | name = "implicit-clone" 579 | version = "0.4.9" 580 | source = "registry+https://github.com/rust-lang/crates.io-index" 581 | checksum = "f8a9aa791c7b5a71b636b7a68207fdebf171ddfc593d9c8506ec4cbc527b6a84" 582 | dependencies = [ 583 | "implicit-clone-derive", 584 | "indexmap", 585 | ] 586 | 587 | [[package]] 588 | name = "implicit-clone-derive" 589 | version = "0.1.2" 590 | source = "registry+https://github.com/rust-lang/crates.io-index" 591 | checksum = "699c1b6d335e63d0ba5c1e1c7f647371ce989c3bcbe1f7ed2b85fa56e3bd1a21" 592 | dependencies = [ 593 | "quote", 594 | "syn 2.0.100", 595 | ] 596 | 597 | [[package]] 598 | name = "indexmap" 599 | version = "2.8.0" 600 | source = "registry+https://github.com/rust-lang/crates.io-index" 601 | checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" 602 | dependencies = [ 603 | "equivalent", 604 | "hashbrown", 605 | ] 606 | 607 | [[package]] 608 | name = "itoa" 609 | version = "1.0.15" 610 | source = "registry+https://github.com/rust-lang/crates.io-index" 611 | checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" 612 | 613 | [[package]] 614 | name = "js-sys" 615 | version = "0.3.77" 616 | source = "registry+https://github.com/rust-lang/crates.io-index" 617 | checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" 618 | dependencies = [ 619 | "once_cell", 620 | "wasm-bindgen", 621 | ] 622 | 623 | [[package]] 624 | name = "libc" 625 | version = "0.2.171" 626 | source = "registry+https://github.com/rust-lang/crates.io-index" 627 | checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" 628 | 629 | [[package]] 630 | name = "log" 631 | version = "0.4.26" 632 | source = "registry+https://github.com/rust-lang/crates.io-index" 633 | checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" 634 | 635 | [[package]] 636 | name = "memchr" 637 | version = "2.7.4" 638 | source = "registry+https://github.com/rust-lang/crates.io-index" 639 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 640 | 641 | [[package]] 642 | name = "miniz_oxide" 643 | version = "0.8.5" 644 | source = "registry+https://github.com/rust-lang/crates.io-index" 645 | checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" 646 | dependencies = [ 647 | "adler2", 648 | ] 649 | 650 | [[package]] 651 | name = "num_cpus" 652 | version = "1.16.0" 653 | source = "registry+https://github.com/rust-lang/crates.io-index" 654 | checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" 655 | dependencies = [ 656 | "hermit-abi", 657 | "libc", 658 | ] 659 | 660 | [[package]] 661 | name = "object" 662 | version = "0.36.7" 663 | source = "registry+https://github.com/rust-lang/crates.io-index" 664 | checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" 665 | dependencies = [ 666 | "memchr", 667 | ] 668 | 669 | [[package]] 670 | name = "once_cell" 671 | version = "1.21.1" 672 | source = "registry+https://github.com/rust-lang/crates.io-index" 673 | checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" 674 | 675 | [[package]] 676 | name = "percent-encoding" 677 | version = "2.3.1" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" 680 | 681 | [[package]] 682 | name = "pin-project" 683 | version = "1.1.10" 684 | source = "registry+https://github.com/rust-lang/crates.io-index" 685 | checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" 686 | dependencies = [ 687 | "pin-project-internal", 688 | ] 689 | 690 | [[package]] 691 | name = "pin-project-internal" 692 | version = "1.1.10" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" 695 | dependencies = [ 696 | "proc-macro2", 697 | "quote", 698 | "syn 2.0.100", 699 | ] 700 | 701 | [[package]] 702 | name = "pin-project-lite" 703 | version = "0.2.16" 704 | source = "registry+https://github.com/rust-lang/crates.io-index" 705 | checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" 706 | 707 | [[package]] 708 | name = "pin-utils" 709 | version = "0.1.0" 710 | source = "registry+https://github.com/rust-lang/crates.io-index" 711 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 712 | 713 | [[package]] 714 | name = "pinned" 715 | version = "0.1.0" 716 | source = "registry+https://github.com/rust-lang/crates.io-index" 717 | checksum = "a829027bd95e54cfe13e3e258a1ae7b645960553fb82b75ff852c29688ee595b" 718 | dependencies = [ 719 | "futures", 720 | "rustversion", 721 | "thiserror", 722 | ] 723 | 724 | [[package]] 725 | name = "prettyplease" 726 | version = "0.2.31" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" 729 | dependencies = [ 730 | "proc-macro2", 731 | "syn 2.0.100", 732 | ] 733 | 734 | [[package]] 735 | name = "proc-macro-crate" 736 | version = "1.3.1" 737 | source = "registry+https://github.com/rust-lang/crates.io-index" 738 | checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" 739 | dependencies = [ 740 | "once_cell", 741 | "toml_edit", 742 | ] 743 | 744 | [[package]] 745 | name = "proc-macro-error" 746 | version = "1.0.4" 747 | source = "registry+https://github.com/rust-lang/crates.io-index" 748 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 749 | dependencies = [ 750 | "proc-macro-error-attr", 751 | "proc-macro2", 752 | "quote", 753 | "syn 1.0.109", 754 | "version_check", 755 | ] 756 | 757 | [[package]] 758 | name = "proc-macro-error-attr" 759 | version = "1.0.4" 760 | source = "registry+https://github.com/rust-lang/crates.io-index" 761 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 762 | dependencies = [ 763 | "proc-macro2", 764 | "quote", 765 | "version_check", 766 | ] 767 | 768 | [[package]] 769 | name = "proc-macro2" 770 | version = "1.0.94" 771 | source = "registry+https://github.com/rust-lang/crates.io-index" 772 | checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" 773 | dependencies = [ 774 | "unicode-ident", 775 | ] 776 | 777 | [[package]] 778 | name = "prokio" 779 | version = "0.1.0" 780 | source = "registry+https://github.com/rust-lang/crates.io-index" 781 | checksum = "03b55e106e5791fa5a13abd13c85d6127312e8e09098059ca2bc9b03ca4cf488" 782 | dependencies = [ 783 | "futures", 784 | "gloo 0.8.1", 785 | "num_cpus", 786 | "once_cell", 787 | "pin-project", 788 | "pinned", 789 | "tokio", 790 | "tokio-stream", 791 | "wasm-bindgen-futures", 792 | ] 793 | 794 | [[package]] 795 | name = "quote" 796 | version = "1.0.40" 797 | source = "registry+https://github.com/rust-lang/crates.io-index" 798 | checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 799 | dependencies = [ 800 | "proc-macro2", 801 | ] 802 | 803 | [[package]] 804 | name = "rustc-demangle" 805 | version = "0.1.24" 806 | source = "registry+https://github.com/rust-lang/crates.io-index" 807 | checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" 808 | 809 | [[package]] 810 | name = "rustversion" 811 | version = "1.0.20" 812 | source = "registry+https://github.com/rust-lang/crates.io-index" 813 | checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" 814 | 815 | [[package]] 816 | name = "ryu" 817 | version = "1.0.20" 818 | source = "registry+https://github.com/rust-lang/crates.io-index" 819 | checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" 820 | 821 | [[package]] 822 | name = "serde" 823 | version = "1.0.219" 824 | source = "registry+https://github.com/rust-lang/crates.io-index" 825 | checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" 826 | dependencies = [ 827 | "serde_derive", 828 | ] 829 | 830 | [[package]] 831 | name = "serde-wasm-bindgen" 832 | version = "0.5.0" 833 | source = "registry+https://github.com/rust-lang/crates.io-index" 834 | checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" 835 | dependencies = [ 836 | "js-sys", 837 | "serde", 838 | "wasm-bindgen", 839 | ] 840 | 841 | [[package]] 842 | name = "serde-wasm-bindgen" 843 | version = "0.6.5" 844 | source = "registry+https://github.com/rust-lang/crates.io-index" 845 | checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" 846 | dependencies = [ 847 | "js-sys", 848 | "serde", 849 | "wasm-bindgen", 850 | ] 851 | 852 | [[package]] 853 | name = "serde_derive" 854 | version = "1.0.219" 855 | source = "registry+https://github.com/rust-lang/crates.io-index" 856 | checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" 857 | dependencies = [ 858 | "proc-macro2", 859 | "quote", 860 | "syn 2.0.100", 861 | ] 862 | 863 | [[package]] 864 | name = "serde_json" 865 | version = "1.0.140" 866 | source = "registry+https://github.com/rust-lang/crates.io-index" 867 | checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" 868 | dependencies = [ 869 | "itoa", 870 | "memchr", 871 | "ryu", 872 | "serde", 873 | ] 874 | 875 | [[package]] 876 | name = "serde_urlencoded" 877 | version = "0.7.1" 878 | source = "registry+https://github.com/rust-lang/crates.io-index" 879 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 880 | dependencies = [ 881 | "form_urlencoded", 882 | "itoa", 883 | "ryu", 884 | "serde", 885 | ] 886 | 887 | [[package]] 888 | name = "slab" 889 | version = "0.4.9" 890 | source = "registry+https://github.com/rust-lang/crates.io-index" 891 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 892 | dependencies = [ 893 | "autocfg", 894 | ] 895 | 896 | [[package]] 897 | name = "syn" 898 | version = "1.0.109" 899 | source = "registry+https://github.com/rust-lang/crates.io-index" 900 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 901 | dependencies = [ 902 | "proc-macro2", 903 | "unicode-ident", 904 | ] 905 | 906 | [[package]] 907 | name = "syn" 908 | version = "2.0.100" 909 | source = "registry+https://github.com/rust-lang/crates.io-index" 910 | checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" 911 | dependencies = [ 912 | "proc-macro2", 913 | "quote", 914 | "unicode-ident", 915 | ] 916 | 917 | [[package]] 918 | name = "thiserror" 919 | version = "1.0.69" 920 | source = "registry+https://github.com/rust-lang/crates.io-index" 921 | checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" 922 | dependencies = [ 923 | "thiserror-impl", 924 | ] 925 | 926 | [[package]] 927 | name = "thiserror-impl" 928 | version = "1.0.69" 929 | source = "registry+https://github.com/rust-lang/crates.io-index" 930 | checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" 931 | dependencies = [ 932 | "proc-macro2", 933 | "quote", 934 | "syn 2.0.100", 935 | ] 936 | 937 | [[package]] 938 | name = "tokio" 939 | version = "1.44.1" 940 | source = "registry+https://github.com/rust-lang/crates.io-index" 941 | checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" 942 | dependencies = [ 943 | "backtrace", 944 | "pin-project-lite", 945 | ] 946 | 947 | [[package]] 948 | name = "tokio-stream" 949 | version = "0.1.17" 950 | source = "registry+https://github.com/rust-lang/crates.io-index" 951 | checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" 952 | dependencies = [ 953 | "futures-core", 954 | "pin-project-lite", 955 | "tokio", 956 | ] 957 | 958 | [[package]] 959 | name = "toml_datetime" 960 | version = "0.6.8" 961 | source = "registry+https://github.com/rust-lang/crates.io-index" 962 | checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" 963 | 964 | [[package]] 965 | name = "toml_edit" 966 | version = "0.19.15" 967 | source = "registry+https://github.com/rust-lang/crates.io-index" 968 | checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" 969 | dependencies = [ 970 | "indexmap", 971 | "toml_datetime", 972 | "winnow", 973 | ] 974 | 975 | [[package]] 976 | name = "tracing" 977 | version = "0.1.41" 978 | source = "registry+https://github.com/rust-lang/crates.io-index" 979 | checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" 980 | dependencies = [ 981 | "pin-project-lite", 982 | "tracing-attributes", 983 | "tracing-core", 984 | ] 985 | 986 | [[package]] 987 | name = "tracing-attributes" 988 | version = "0.1.28" 989 | source = "registry+https://github.com/rust-lang/crates.io-index" 990 | checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" 991 | dependencies = [ 992 | "proc-macro2", 993 | "quote", 994 | "syn 2.0.100", 995 | ] 996 | 997 | [[package]] 998 | name = "tracing-core" 999 | version = "0.1.33" 1000 | source = "registry+https://github.com/rust-lang/crates.io-index" 1001 | checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" 1002 | dependencies = [ 1003 | "once_cell", 1004 | ] 1005 | 1006 | [[package]] 1007 | name = "unicode-ident" 1008 | version = "1.0.18" 1009 | source = "registry+https://github.com/rust-lang/crates.io-index" 1010 | checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" 1011 | 1012 | [[package]] 1013 | name = "version_check" 1014 | version = "0.9.5" 1015 | source = "registry+https://github.com/rust-lang/crates.io-index" 1016 | checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" 1017 | 1018 | [[package]] 1019 | name = "wasi" 1020 | version = "0.11.0+wasi-snapshot-preview1" 1021 | source = "registry+https://github.com/rust-lang/crates.io-index" 1022 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1023 | 1024 | [[package]] 1025 | name = "wasm-bindgen" 1026 | version = "0.2.100" 1027 | source = "registry+https://github.com/rust-lang/crates.io-index" 1028 | checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" 1029 | dependencies = [ 1030 | "cfg-if", 1031 | "once_cell", 1032 | "rustversion", 1033 | "wasm-bindgen-macro", 1034 | ] 1035 | 1036 | [[package]] 1037 | name = "wasm-bindgen-backend" 1038 | version = "0.2.100" 1039 | source = "registry+https://github.com/rust-lang/crates.io-index" 1040 | checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" 1041 | dependencies = [ 1042 | "bumpalo", 1043 | "log", 1044 | "proc-macro2", 1045 | "quote", 1046 | "syn 2.0.100", 1047 | "wasm-bindgen-shared", 1048 | ] 1049 | 1050 | [[package]] 1051 | name = "wasm-bindgen-futures" 1052 | version = "0.4.50" 1053 | source = "registry+https://github.com/rust-lang/crates.io-index" 1054 | checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" 1055 | dependencies = [ 1056 | "cfg-if", 1057 | "js-sys", 1058 | "once_cell", 1059 | "wasm-bindgen", 1060 | "web-sys", 1061 | ] 1062 | 1063 | [[package]] 1064 | name = "wasm-bindgen-macro" 1065 | version = "0.2.100" 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" 1067 | checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" 1068 | dependencies = [ 1069 | "quote", 1070 | "wasm-bindgen-macro-support", 1071 | ] 1072 | 1073 | [[package]] 1074 | name = "wasm-bindgen-macro-support" 1075 | version = "0.2.100" 1076 | source = "registry+https://github.com/rust-lang/crates.io-index" 1077 | checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" 1078 | dependencies = [ 1079 | "proc-macro2", 1080 | "quote", 1081 | "syn 2.0.100", 1082 | "wasm-bindgen-backend", 1083 | "wasm-bindgen-shared", 1084 | ] 1085 | 1086 | [[package]] 1087 | name = "wasm-bindgen-shared" 1088 | version = "0.2.100" 1089 | source = "registry+https://github.com/rust-lang/crates.io-index" 1090 | checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" 1091 | dependencies = [ 1092 | "unicode-ident", 1093 | ] 1094 | 1095 | [[package]] 1096 | name = "web-sys" 1097 | version = "0.3.77" 1098 | source = "registry+https://github.com/rust-lang/crates.io-index" 1099 | checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" 1100 | dependencies = [ 1101 | "js-sys", 1102 | "wasm-bindgen", 1103 | ] 1104 | 1105 | [[package]] 1106 | name = "windows-targets" 1107 | version = "0.52.6" 1108 | source = "registry+https://github.com/rust-lang/crates.io-index" 1109 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1110 | dependencies = [ 1111 | "windows_aarch64_gnullvm", 1112 | "windows_aarch64_msvc", 1113 | "windows_i686_gnu", 1114 | "windows_i686_gnullvm", 1115 | "windows_i686_msvc", 1116 | "windows_x86_64_gnu", 1117 | "windows_x86_64_gnullvm", 1118 | "windows_x86_64_msvc", 1119 | ] 1120 | 1121 | [[package]] 1122 | name = "windows_aarch64_gnullvm" 1123 | version = "0.52.6" 1124 | source = "registry+https://github.com/rust-lang/crates.io-index" 1125 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1126 | 1127 | [[package]] 1128 | name = "windows_aarch64_msvc" 1129 | version = "0.52.6" 1130 | source = "registry+https://github.com/rust-lang/crates.io-index" 1131 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1132 | 1133 | [[package]] 1134 | name = "windows_i686_gnu" 1135 | version = "0.52.6" 1136 | source = "registry+https://github.com/rust-lang/crates.io-index" 1137 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1138 | 1139 | [[package]] 1140 | name = "windows_i686_gnullvm" 1141 | version = "0.52.6" 1142 | source = "registry+https://github.com/rust-lang/crates.io-index" 1143 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1144 | 1145 | [[package]] 1146 | name = "windows_i686_msvc" 1147 | version = "0.52.6" 1148 | source = "registry+https://github.com/rust-lang/crates.io-index" 1149 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1150 | 1151 | [[package]] 1152 | name = "windows_x86_64_gnu" 1153 | version = "0.52.6" 1154 | source = "registry+https://github.com/rust-lang/crates.io-index" 1155 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1156 | 1157 | [[package]] 1158 | name = "windows_x86_64_gnullvm" 1159 | version = "0.52.6" 1160 | source = "registry+https://github.com/rust-lang/crates.io-index" 1161 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1162 | 1163 | [[package]] 1164 | name = "windows_x86_64_msvc" 1165 | version = "0.52.6" 1166 | source = "registry+https://github.com/rust-lang/crates.io-index" 1167 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1168 | 1169 | [[package]] 1170 | name = "winnow" 1171 | version = "0.5.40" 1172 | source = "registry+https://github.com/rust-lang/crates.io-index" 1173 | checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" 1174 | dependencies = [ 1175 | "memchr", 1176 | ] 1177 | 1178 | [[package]] 1179 | name = "yew" 1180 | version = "0.21.0" 1181 | source = "registry+https://github.com/rust-lang/crates.io-index" 1182 | checksum = "5f1a03f255c70c7aa3e9c62e15292f142ede0564123543c1cc0c7a4f31660cac" 1183 | dependencies = [ 1184 | "console_error_panic_hook", 1185 | "futures", 1186 | "gloo 0.10.0", 1187 | "implicit-clone", 1188 | "indexmap", 1189 | "js-sys", 1190 | "prokio", 1191 | "rustversion", 1192 | "serde", 1193 | "slab", 1194 | "thiserror", 1195 | "tokio", 1196 | "tracing", 1197 | "wasm-bindgen", 1198 | "wasm-bindgen-futures", 1199 | "web-sys", 1200 | "yew-macro", 1201 | ] 1202 | 1203 | [[package]] 1204 | name = "yew-demo" 1205 | version = "0.1.0" 1206 | dependencies = [ 1207 | "yew", 1208 | ] 1209 | 1210 | [[package]] 1211 | name = "yew-macro" 1212 | version = "0.21.0" 1213 | source = "registry+https://github.com/rust-lang/crates.io-index" 1214 | checksum = "02fd8ca5166d69e59f796500a2ce432ff751edecbbb308ca59fd3fe4d0343de2" 1215 | dependencies = [ 1216 | "boolinator", 1217 | "once_cell", 1218 | "prettyplease", 1219 | "proc-macro-error", 1220 | "proc-macro2", 1221 | "quote", 1222 | "syn 2.0.100", 1223 | ] 1224 | -------------------------------------------------------------------------------- /lec11/sqlx-demo/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "ahash" 7 | version = "0.7.6" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 10 | dependencies = [ 11 | "getrandom", 12 | "once_cell", 13 | "version_check", 14 | ] 15 | 16 | [[package]] 17 | name = "atoi" 18 | version = "1.0.0" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" 21 | dependencies = [ 22 | "num-traits", 23 | ] 24 | 25 | [[package]] 26 | name = "autocfg" 27 | version = "1.1.0" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 30 | 31 | [[package]] 32 | name = "bitflags" 33 | version = "1.3.2" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 36 | 37 | [[package]] 38 | name = "block-buffer" 39 | version = "0.10.4" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" 42 | dependencies = [ 43 | "generic-array", 44 | ] 45 | 46 | [[package]] 47 | name = "byteorder" 48 | version = "1.4.3" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 51 | 52 | [[package]] 53 | name = "bytes" 54 | version = "1.4.0" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" 57 | 58 | [[package]] 59 | name = "cc" 60 | version = "1.0.79" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 63 | 64 | [[package]] 65 | name = "cfg-if" 66 | version = "1.0.0" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 69 | 70 | [[package]] 71 | name = "core-foundation" 72 | version = "0.9.3" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" 75 | dependencies = [ 76 | "core-foundation-sys", 77 | "libc", 78 | ] 79 | 80 | [[package]] 81 | name = "core-foundation-sys" 82 | version = "0.8.3" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" 85 | 86 | [[package]] 87 | name = "cpufeatures" 88 | version = "0.2.6" 89 | source = "registry+https://github.com/rust-lang/crates.io-index" 90 | checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" 91 | dependencies = [ 92 | "libc", 93 | ] 94 | 95 | [[package]] 96 | name = "crc" 97 | version = "3.0.1" 98 | source = "registry+https://github.com/rust-lang/crates.io-index" 99 | checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" 100 | dependencies = [ 101 | "crc-catalog", 102 | ] 103 | 104 | [[package]] 105 | name = "crc-catalog" 106 | version = "2.2.0" 107 | source = "registry+https://github.com/rust-lang/crates.io-index" 108 | checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" 109 | 110 | [[package]] 111 | name = "crossbeam-queue" 112 | version = "0.3.8" 113 | source = "registry+https://github.com/rust-lang/crates.io-index" 114 | checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" 115 | dependencies = [ 116 | "cfg-if", 117 | "crossbeam-utils", 118 | ] 119 | 120 | [[package]] 121 | name = "crossbeam-utils" 122 | version = "0.8.15" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" 125 | dependencies = [ 126 | "cfg-if", 127 | ] 128 | 129 | [[package]] 130 | name = "crypto-common" 131 | version = "0.1.6" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 134 | dependencies = [ 135 | "generic-array", 136 | "typenum", 137 | ] 138 | 139 | [[package]] 140 | name = "digest" 141 | version = "0.10.6" 142 | source = "registry+https://github.com/rust-lang/crates.io-index" 143 | checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" 144 | dependencies = [ 145 | "block-buffer", 146 | "crypto-common", 147 | ] 148 | 149 | [[package]] 150 | name = "dotenvy" 151 | version = "0.15.7" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" 154 | 155 | [[package]] 156 | name = "either" 157 | version = "1.8.1" 158 | source = "registry+https://github.com/rust-lang/crates.io-index" 159 | checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" 160 | 161 | [[package]] 162 | name = "errno" 163 | version = "0.2.8" 164 | source = "registry+https://github.com/rust-lang/crates.io-index" 165 | checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" 166 | dependencies = [ 167 | "errno-dragonfly", 168 | "libc", 169 | "winapi", 170 | ] 171 | 172 | [[package]] 173 | name = "errno-dragonfly" 174 | version = "0.1.2" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" 177 | dependencies = [ 178 | "cc", 179 | "libc", 180 | ] 181 | 182 | [[package]] 183 | name = "event-listener" 184 | version = "2.5.3" 185 | source = "registry+https://github.com/rust-lang/crates.io-index" 186 | checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" 187 | 188 | [[package]] 189 | name = "fastrand" 190 | version = "1.9.0" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" 193 | dependencies = [ 194 | "instant", 195 | ] 196 | 197 | [[package]] 198 | name = "flume" 199 | version = "0.10.14" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" 202 | dependencies = [ 203 | "futures-core", 204 | "futures-sink", 205 | "pin-project", 206 | "spin", 207 | ] 208 | 209 | [[package]] 210 | name = "foreign-types" 211 | version = "0.3.2" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" 214 | dependencies = [ 215 | "foreign-types-shared", 216 | ] 217 | 218 | [[package]] 219 | name = "foreign-types-shared" 220 | version = "0.1.1" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" 223 | 224 | [[package]] 225 | name = "form_urlencoded" 226 | version = "1.1.0" 227 | source = "registry+https://github.com/rust-lang/crates.io-index" 228 | checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" 229 | dependencies = [ 230 | "percent-encoding", 231 | ] 232 | 233 | [[package]] 234 | name = "futures-channel" 235 | version = "0.3.27" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" 238 | dependencies = [ 239 | "futures-core", 240 | "futures-sink", 241 | ] 242 | 243 | [[package]] 244 | name = "futures-core" 245 | version = "0.3.27" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" 248 | 249 | [[package]] 250 | name = "futures-executor" 251 | version = "0.3.27" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" 254 | dependencies = [ 255 | "futures-core", 256 | "futures-task", 257 | "futures-util", 258 | ] 259 | 260 | [[package]] 261 | name = "futures-intrusive" 262 | version = "0.4.2" 263 | source = "registry+https://github.com/rust-lang/crates.io-index" 264 | checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" 265 | dependencies = [ 266 | "futures-core", 267 | "lock_api", 268 | "parking_lot 0.11.2", 269 | ] 270 | 271 | [[package]] 272 | name = "futures-sink" 273 | version = "0.3.27" 274 | source = "registry+https://github.com/rust-lang/crates.io-index" 275 | checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" 276 | 277 | [[package]] 278 | name = "futures-task" 279 | version = "0.3.27" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" 282 | 283 | [[package]] 284 | name = "futures-util" 285 | version = "0.3.27" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" 288 | dependencies = [ 289 | "futures-core", 290 | "futures-sink", 291 | "futures-task", 292 | "pin-project-lite", 293 | "pin-utils", 294 | "slab", 295 | ] 296 | 297 | [[package]] 298 | name = "generic-array" 299 | version = "0.14.6" 300 | source = "registry+https://github.com/rust-lang/crates.io-index" 301 | checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" 302 | dependencies = [ 303 | "typenum", 304 | "version_check", 305 | ] 306 | 307 | [[package]] 308 | name = "getrandom" 309 | version = "0.2.8" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" 312 | dependencies = [ 313 | "cfg-if", 314 | "libc", 315 | "wasi", 316 | ] 317 | 318 | [[package]] 319 | name = "hashbrown" 320 | version = "0.12.3" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 323 | dependencies = [ 324 | "ahash", 325 | ] 326 | 327 | [[package]] 328 | name = "hashlink" 329 | version = "0.8.1" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" 332 | dependencies = [ 333 | "hashbrown", 334 | ] 335 | 336 | [[package]] 337 | name = "heck" 338 | version = "0.4.1" 339 | source = "registry+https://github.com/rust-lang/crates.io-index" 340 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 341 | dependencies = [ 342 | "unicode-segmentation", 343 | ] 344 | 345 | [[package]] 346 | name = "hermit-abi" 347 | version = "0.2.6" 348 | source = "registry+https://github.com/rust-lang/crates.io-index" 349 | checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" 350 | dependencies = [ 351 | "libc", 352 | ] 353 | 354 | [[package]] 355 | name = "hermit-abi" 356 | version = "0.3.1" 357 | source = "registry+https://github.com/rust-lang/crates.io-index" 358 | checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" 359 | 360 | [[package]] 361 | name = "hex" 362 | version = "0.4.3" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 365 | 366 | [[package]] 367 | name = "idna" 368 | version = "0.3.0" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" 371 | dependencies = [ 372 | "unicode-bidi", 373 | "unicode-normalization", 374 | ] 375 | 376 | [[package]] 377 | name = "indexmap" 378 | version = "1.9.3" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" 381 | dependencies = [ 382 | "autocfg", 383 | "hashbrown", 384 | ] 385 | 386 | [[package]] 387 | name = "instant" 388 | version = "0.1.12" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 391 | dependencies = [ 392 | "cfg-if", 393 | ] 394 | 395 | [[package]] 396 | name = "io-lifetimes" 397 | version = "1.0.9" 398 | source = "registry+https://github.com/rust-lang/crates.io-index" 399 | checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" 400 | dependencies = [ 401 | "hermit-abi 0.3.1", 402 | "libc", 403 | "windows-sys 0.45.0", 404 | ] 405 | 406 | [[package]] 407 | name = "itertools" 408 | version = "0.10.5" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" 411 | dependencies = [ 412 | "either", 413 | ] 414 | 415 | [[package]] 416 | name = "itoa" 417 | version = "1.0.6" 418 | source = "registry+https://github.com/rust-lang/crates.io-index" 419 | checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" 420 | 421 | [[package]] 422 | name = "lazy_static" 423 | version = "1.4.0" 424 | source = "registry+https://github.com/rust-lang/crates.io-index" 425 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 426 | 427 | [[package]] 428 | name = "libc" 429 | version = "0.2.140" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" 432 | 433 | [[package]] 434 | name = "libsqlite3-sys" 435 | version = "0.24.2" 436 | source = "registry+https://github.com/rust-lang/crates.io-index" 437 | checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" 438 | dependencies = [ 439 | "cc", 440 | "pkg-config", 441 | "vcpkg", 442 | ] 443 | 444 | [[package]] 445 | name = "linux-raw-sys" 446 | version = "0.1.4" 447 | source = "registry+https://github.com/rust-lang/crates.io-index" 448 | checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" 449 | 450 | [[package]] 451 | name = "lock_api" 452 | version = "0.4.9" 453 | source = "registry+https://github.com/rust-lang/crates.io-index" 454 | checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 455 | dependencies = [ 456 | "autocfg", 457 | "scopeguard", 458 | ] 459 | 460 | [[package]] 461 | name = "log" 462 | version = "0.4.17" 463 | source = "registry+https://github.com/rust-lang/crates.io-index" 464 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 465 | dependencies = [ 466 | "cfg-if", 467 | ] 468 | 469 | [[package]] 470 | name = "memchr" 471 | version = "2.5.0" 472 | source = "registry+https://github.com/rust-lang/crates.io-index" 473 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 474 | 475 | [[package]] 476 | name = "minimal-lexical" 477 | version = "0.2.1" 478 | source = "registry+https://github.com/rust-lang/crates.io-index" 479 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 480 | 481 | [[package]] 482 | name = "mio" 483 | version = "0.8.6" 484 | source = "registry+https://github.com/rust-lang/crates.io-index" 485 | checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" 486 | dependencies = [ 487 | "libc", 488 | "log", 489 | "wasi", 490 | "windows-sys 0.45.0", 491 | ] 492 | 493 | [[package]] 494 | name = "native-tls" 495 | version = "0.2.11" 496 | source = "registry+https://github.com/rust-lang/crates.io-index" 497 | checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" 498 | dependencies = [ 499 | "lazy_static", 500 | "libc", 501 | "log", 502 | "openssl", 503 | "openssl-probe", 504 | "openssl-sys", 505 | "schannel", 506 | "security-framework", 507 | "security-framework-sys", 508 | "tempfile", 509 | ] 510 | 511 | [[package]] 512 | name = "nom" 513 | version = "7.1.3" 514 | source = "registry+https://github.com/rust-lang/crates.io-index" 515 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" 516 | dependencies = [ 517 | "memchr", 518 | "minimal-lexical", 519 | ] 520 | 521 | [[package]] 522 | name = "num-traits" 523 | version = "0.2.15" 524 | source = "registry+https://github.com/rust-lang/crates.io-index" 525 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 526 | dependencies = [ 527 | "autocfg", 528 | ] 529 | 530 | [[package]] 531 | name = "num_cpus" 532 | version = "1.15.0" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" 535 | dependencies = [ 536 | "hermit-abi 0.2.6", 537 | "libc", 538 | ] 539 | 540 | [[package]] 541 | name = "once_cell" 542 | version = "1.17.1" 543 | source = "registry+https://github.com/rust-lang/crates.io-index" 544 | checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" 545 | 546 | [[package]] 547 | name = "openssl" 548 | version = "0.10.48" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "518915b97df115dd36109bfa429a48b8f737bd05508cf9588977b599648926d2" 551 | dependencies = [ 552 | "bitflags", 553 | "cfg-if", 554 | "foreign-types", 555 | "libc", 556 | "once_cell", 557 | "openssl-macros", 558 | "openssl-sys", 559 | ] 560 | 561 | [[package]] 562 | name = "openssl-macros" 563 | version = "0.1.0" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" 566 | dependencies = [ 567 | "proc-macro2", 568 | "quote", 569 | "syn 1.0.109", 570 | ] 571 | 572 | [[package]] 573 | name = "openssl-probe" 574 | version = "0.1.5" 575 | source = "registry+https://github.com/rust-lang/crates.io-index" 576 | checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" 577 | 578 | [[package]] 579 | name = "openssl-sys" 580 | version = "0.9.83" 581 | source = "registry+https://github.com/rust-lang/crates.io-index" 582 | checksum = "666416d899cf077260dac8698d60a60b435a46d57e82acb1be3d0dad87284e5b" 583 | dependencies = [ 584 | "autocfg", 585 | "cc", 586 | "libc", 587 | "pkg-config", 588 | "vcpkg", 589 | ] 590 | 591 | [[package]] 592 | name = "parking_lot" 593 | version = "0.11.2" 594 | source = "registry+https://github.com/rust-lang/crates.io-index" 595 | checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" 596 | dependencies = [ 597 | "instant", 598 | "lock_api", 599 | "parking_lot_core 0.8.6", 600 | ] 601 | 602 | [[package]] 603 | name = "parking_lot" 604 | version = "0.12.1" 605 | source = "registry+https://github.com/rust-lang/crates.io-index" 606 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 607 | dependencies = [ 608 | "lock_api", 609 | "parking_lot_core 0.9.7", 610 | ] 611 | 612 | [[package]] 613 | name = "parking_lot_core" 614 | version = "0.8.6" 615 | source = "registry+https://github.com/rust-lang/crates.io-index" 616 | checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" 617 | dependencies = [ 618 | "cfg-if", 619 | "instant", 620 | "libc", 621 | "redox_syscall", 622 | "smallvec", 623 | "winapi", 624 | ] 625 | 626 | [[package]] 627 | name = "parking_lot_core" 628 | version = "0.9.7" 629 | source = "registry+https://github.com/rust-lang/crates.io-index" 630 | checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" 631 | dependencies = [ 632 | "cfg-if", 633 | "libc", 634 | "redox_syscall", 635 | "smallvec", 636 | "windows-sys 0.45.0", 637 | ] 638 | 639 | [[package]] 640 | name = "paste" 641 | version = "1.0.12" 642 | source = "registry+https://github.com/rust-lang/crates.io-index" 643 | checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" 644 | 645 | [[package]] 646 | name = "percent-encoding" 647 | version = "2.2.0" 648 | source = "registry+https://github.com/rust-lang/crates.io-index" 649 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 650 | 651 | [[package]] 652 | name = "pin-project" 653 | version = "1.0.12" 654 | source = "registry+https://github.com/rust-lang/crates.io-index" 655 | checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" 656 | dependencies = [ 657 | "pin-project-internal", 658 | ] 659 | 660 | [[package]] 661 | name = "pin-project-internal" 662 | version = "1.0.12" 663 | source = "registry+https://github.com/rust-lang/crates.io-index" 664 | checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" 665 | dependencies = [ 666 | "proc-macro2", 667 | "quote", 668 | "syn 1.0.109", 669 | ] 670 | 671 | [[package]] 672 | name = "pin-project-lite" 673 | version = "0.2.9" 674 | source = "registry+https://github.com/rust-lang/crates.io-index" 675 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 676 | 677 | [[package]] 678 | name = "pin-utils" 679 | version = "0.1.0" 680 | source = "registry+https://github.com/rust-lang/crates.io-index" 681 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 682 | 683 | [[package]] 684 | name = "pkg-config" 685 | version = "0.3.26" 686 | source = "registry+https://github.com/rust-lang/crates.io-index" 687 | checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" 688 | 689 | [[package]] 690 | name = "proc-macro2" 691 | version = "1.0.54" 692 | source = "registry+https://github.com/rust-lang/crates.io-index" 693 | checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" 694 | dependencies = [ 695 | "unicode-ident", 696 | ] 697 | 698 | [[package]] 699 | name = "quote" 700 | version = "1.0.26" 701 | source = "registry+https://github.com/rust-lang/crates.io-index" 702 | checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" 703 | dependencies = [ 704 | "proc-macro2", 705 | ] 706 | 707 | [[package]] 708 | name = "redox_syscall" 709 | version = "0.2.16" 710 | source = "registry+https://github.com/rust-lang/crates.io-index" 711 | checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 712 | dependencies = [ 713 | "bitflags", 714 | ] 715 | 716 | [[package]] 717 | name = "rustix" 718 | version = "0.36.11" 719 | source = "registry+https://github.com/rust-lang/crates.io-index" 720 | checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" 721 | dependencies = [ 722 | "bitflags", 723 | "errno", 724 | "io-lifetimes", 725 | "libc", 726 | "linux-raw-sys", 727 | "windows-sys 0.45.0", 728 | ] 729 | 730 | [[package]] 731 | name = "schannel" 732 | version = "0.1.21" 733 | source = "registry+https://github.com/rust-lang/crates.io-index" 734 | checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" 735 | dependencies = [ 736 | "windows-sys 0.42.0", 737 | ] 738 | 739 | [[package]] 740 | name = "scopeguard" 741 | version = "1.1.0" 742 | source = "registry+https://github.com/rust-lang/crates.io-index" 743 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 744 | 745 | [[package]] 746 | name = "security-framework" 747 | version = "2.8.2" 748 | source = "registry+https://github.com/rust-lang/crates.io-index" 749 | checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" 750 | dependencies = [ 751 | "bitflags", 752 | "core-foundation", 753 | "core-foundation-sys", 754 | "libc", 755 | "security-framework-sys", 756 | ] 757 | 758 | [[package]] 759 | name = "security-framework-sys" 760 | version = "2.8.0" 761 | source = "registry+https://github.com/rust-lang/crates.io-index" 762 | checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" 763 | dependencies = [ 764 | "core-foundation-sys", 765 | "libc", 766 | ] 767 | 768 | [[package]] 769 | name = "sha2" 770 | version = "0.10.6" 771 | source = "registry+https://github.com/rust-lang/crates.io-index" 772 | checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" 773 | dependencies = [ 774 | "cfg-if", 775 | "cpufeatures", 776 | "digest", 777 | ] 778 | 779 | [[package]] 780 | name = "signal-hook-registry" 781 | version = "1.4.1" 782 | source = "registry+https://github.com/rust-lang/crates.io-index" 783 | checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" 784 | dependencies = [ 785 | "libc", 786 | ] 787 | 788 | [[package]] 789 | name = "slab" 790 | version = "0.4.8" 791 | source = "registry+https://github.com/rust-lang/crates.io-index" 792 | checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" 793 | dependencies = [ 794 | "autocfg", 795 | ] 796 | 797 | [[package]] 798 | name = "smallvec" 799 | version = "1.10.0" 800 | source = "registry+https://github.com/rust-lang/crates.io-index" 801 | checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" 802 | 803 | [[package]] 804 | name = "socket2" 805 | version = "0.4.9" 806 | source = "registry+https://github.com/rust-lang/crates.io-index" 807 | checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" 808 | dependencies = [ 809 | "libc", 810 | "winapi", 811 | ] 812 | 813 | [[package]] 814 | name = "spin" 815 | version = "0.9.6" 816 | source = "registry+https://github.com/rust-lang/crates.io-index" 817 | checksum = "b5d6e0250b93c8427a177b849d144a96d5acc57006149479403d7861ab721e34" 818 | dependencies = [ 819 | "lock_api", 820 | ] 821 | 822 | [[package]] 823 | name = "sqlformat" 824 | version = "0.2.1" 825 | source = "registry+https://github.com/rust-lang/crates.io-index" 826 | checksum = "0c12bc9199d1db8234678b7051747c07f517cdcf019262d1847b94ec8b1aee3e" 827 | dependencies = [ 828 | "itertools", 829 | "nom", 830 | "unicode_categories", 831 | ] 832 | 833 | [[package]] 834 | name = "sqlx" 835 | version = "0.6.3" 836 | source = "registry+https://github.com/rust-lang/crates.io-index" 837 | checksum = "f8de3b03a925878ed54a954f621e64bf55a3c1bd29652d0d1a17830405350188" 838 | dependencies = [ 839 | "sqlx-core", 840 | "sqlx-macros", 841 | ] 842 | 843 | [[package]] 844 | name = "sqlx-core" 845 | version = "0.6.3" 846 | source = "registry+https://github.com/rust-lang/crates.io-index" 847 | checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" 848 | dependencies = [ 849 | "ahash", 850 | "atoi", 851 | "bitflags", 852 | "byteorder", 853 | "bytes", 854 | "crc", 855 | "crossbeam-queue", 856 | "dotenvy", 857 | "either", 858 | "event-listener", 859 | "flume", 860 | "futures-channel", 861 | "futures-core", 862 | "futures-executor", 863 | "futures-intrusive", 864 | "futures-util", 865 | "hashlink", 866 | "hex", 867 | "indexmap", 868 | "itoa", 869 | "libc", 870 | "libsqlite3-sys", 871 | "log", 872 | "memchr", 873 | "once_cell", 874 | "paste", 875 | "percent-encoding", 876 | "sha2", 877 | "smallvec", 878 | "sqlformat", 879 | "sqlx-rt", 880 | "stringprep", 881 | "thiserror", 882 | "tokio-stream", 883 | "url", 884 | ] 885 | 886 | [[package]] 887 | name = "sqlx-demo" 888 | version = "0.1.0" 889 | dependencies = [ 890 | "sqlx", 891 | "tokio", 892 | ] 893 | 894 | [[package]] 895 | name = "sqlx-macros" 896 | version = "0.6.3" 897 | source = "registry+https://github.com/rust-lang/crates.io-index" 898 | checksum = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" 899 | dependencies = [ 900 | "dotenvy", 901 | "either", 902 | "heck", 903 | "once_cell", 904 | "proc-macro2", 905 | "quote", 906 | "sha2", 907 | "sqlx-core", 908 | "sqlx-rt", 909 | "syn 1.0.109", 910 | "url", 911 | ] 912 | 913 | [[package]] 914 | name = "sqlx-rt" 915 | version = "0.6.3" 916 | source = "registry+https://github.com/rust-lang/crates.io-index" 917 | checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" 918 | dependencies = [ 919 | "native-tls", 920 | "once_cell", 921 | "tokio", 922 | "tokio-native-tls", 923 | ] 924 | 925 | [[package]] 926 | name = "stringprep" 927 | version = "0.1.2" 928 | source = "registry+https://github.com/rust-lang/crates.io-index" 929 | checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" 930 | dependencies = [ 931 | "unicode-bidi", 932 | "unicode-normalization", 933 | ] 934 | 935 | [[package]] 936 | name = "syn" 937 | version = "1.0.109" 938 | source = "registry+https://github.com/rust-lang/crates.io-index" 939 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 940 | dependencies = [ 941 | "proc-macro2", 942 | "quote", 943 | "unicode-ident", 944 | ] 945 | 946 | [[package]] 947 | name = "syn" 948 | version = "2.0.10" 949 | source = "registry+https://github.com/rust-lang/crates.io-index" 950 | checksum = "5aad1363ed6d37b84299588d62d3a7d95b5a5c2d9aad5c85609fda12afaa1f40" 951 | dependencies = [ 952 | "proc-macro2", 953 | "quote", 954 | "unicode-ident", 955 | ] 956 | 957 | [[package]] 958 | name = "tempfile" 959 | version = "3.4.0" 960 | source = "registry+https://github.com/rust-lang/crates.io-index" 961 | checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" 962 | dependencies = [ 963 | "cfg-if", 964 | "fastrand", 965 | "redox_syscall", 966 | "rustix", 967 | "windows-sys 0.42.0", 968 | ] 969 | 970 | [[package]] 971 | name = "thiserror" 972 | version = "1.0.40" 973 | source = "registry+https://github.com/rust-lang/crates.io-index" 974 | checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" 975 | dependencies = [ 976 | "thiserror-impl", 977 | ] 978 | 979 | [[package]] 980 | name = "thiserror-impl" 981 | version = "1.0.40" 982 | source = "registry+https://github.com/rust-lang/crates.io-index" 983 | checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" 984 | dependencies = [ 985 | "proc-macro2", 986 | "quote", 987 | "syn 2.0.10", 988 | ] 989 | 990 | [[package]] 991 | name = "tinyvec" 992 | version = "1.6.0" 993 | source = "registry+https://github.com/rust-lang/crates.io-index" 994 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 995 | dependencies = [ 996 | "tinyvec_macros", 997 | ] 998 | 999 | [[package]] 1000 | name = "tinyvec_macros" 1001 | version = "0.1.1" 1002 | source = "registry+https://github.com/rust-lang/crates.io-index" 1003 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 1004 | 1005 | [[package]] 1006 | name = "tokio" 1007 | version = "1.26.0" 1008 | source = "registry+https://github.com/rust-lang/crates.io-index" 1009 | checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" 1010 | dependencies = [ 1011 | "autocfg", 1012 | "bytes", 1013 | "libc", 1014 | "memchr", 1015 | "mio", 1016 | "num_cpus", 1017 | "parking_lot 0.12.1", 1018 | "pin-project-lite", 1019 | "signal-hook-registry", 1020 | "socket2", 1021 | "tokio-macros", 1022 | "windows-sys 0.45.0", 1023 | ] 1024 | 1025 | [[package]] 1026 | name = "tokio-macros" 1027 | version = "1.8.2" 1028 | source = "registry+https://github.com/rust-lang/crates.io-index" 1029 | checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" 1030 | dependencies = [ 1031 | "proc-macro2", 1032 | "quote", 1033 | "syn 1.0.109", 1034 | ] 1035 | 1036 | [[package]] 1037 | name = "tokio-native-tls" 1038 | version = "0.3.1" 1039 | source = "registry+https://github.com/rust-lang/crates.io-index" 1040 | checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" 1041 | dependencies = [ 1042 | "native-tls", 1043 | "tokio", 1044 | ] 1045 | 1046 | [[package]] 1047 | name = "tokio-stream" 1048 | version = "0.1.12" 1049 | source = "registry+https://github.com/rust-lang/crates.io-index" 1050 | checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" 1051 | dependencies = [ 1052 | "futures-core", 1053 | "pin-project-lite", 1054 | "tokio", 1055 | ] 1056 | 1057 | [[package]] 1058 | name = "typenum" 1059 | version = "1.16.0" 1060 | source = "registry+https://github.com/rust-lang/crates.io-index" 1061 | checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" 1062 | 1063 | [[package]] 1064 | name = "unicode-bidi" 1065 | version = "0.3.13" 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" 1067 | checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" 1068 | 1069 | [[package]] 1070 | name = "unicode-ident" 1071 | version = "1.0.8" 1072 | source = "registry+https://github.com/rust-lang/crates.io-index" 1073 | checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" 1074 | 1075 | [[package]] 1076 | name = "unicode-normalization" 1077 | version = "0.1.22" 1078 | source = "registry+https://github.com/rust-lang/crates.io-index" 1079 | checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" 1080 | dependencies = [ 1081 | "tinyvec", 1082 | ] 1083 | 1084 | [[package]] 1085 | name = "unicode-segmentation" 1086 | version = "1.10.1" 1087 | source = "registry+https://github.com/rust-lang/crates.io-index" 1088 | checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" 1089 | 1090 | [[package]] 1091 | name = "unicode_categories" 1092 | version = "0.1.1" 1093 | source = "registry+https://github.com/rust-lang/crates.io-index" 1094 | checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" 1095 | 1096 | [[package]] 1097 | name = "url" 1098 | version = "2.3.1" 1099 | source = "registry+https://github.com/rust-lang/crates.io-index" 1100 | checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" 1101 | dependencies = [ 1102 | "form_urlencoded", 1103 | "idna", 1104 | "percent-encoding", 1105 | ] 1106 | 1107 | [[package]] 1108 | name = "vcpkg" 1109 | version = "0.2.15" 1110 | source = "registry+https://github.com/rust-lang/crates.io-index" 1111 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 1112 | 1113 | [[package]] 1114 | name = "version_check" 1115 | version = "0.9.4" 1116 | source = "registry+https://github.com/rust-lang/crates.io-index" 1117 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1118 | 1119 | [[package]] 1120 | name = "wasi" 1121 | version = "0.11.0+wasi-snapshot-preview1" 1122 | source = "registry+https://github.com/rust-lang/crates.io-index" 1123 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1124 | 1125 | [[package]] 1126 | name = "winapi" 1127 | version = "0.3.9" 1128 | source = "registry+https://github.com/rust-lang/crates.io-index" 1129 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1130 | dependencies = [ 1131 | "winapi-i686-pc-windows-gnu", 1132 | "winapi-x86_64-pc-windows-gnu", 1133 | ] 1134 | 1135 | [[package]] 1136 | name = "winapi-i686-pc-windows-gnu" 1137 | version = "0.4.0" 1138 | source = "registry+https://github.com/rust-lang/crates.io-index" 1139 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1140 | 1141 | [[package]] 1142 | name = "winapi-x86_64-pc-windows-gnu" 1143 | version = "0.4.0" 1144 | source = "registry+https://github.com/rust-lang/crates.io-index" 1145 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1146 | 1147 | [[package]] 1148 | name = "windows-sys" 1149 | version = "0.42.0" 1150 | source = "registry+https://github.com/rust-lang/crates.io-index" 1151 | checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" 1152 | dependencies = [ 1153 | "windows_aarch64_gnullvm", 1154 | "windows_aarch64_msvc", 1155 | "windows_i686_gnu", 1156 | "windows_i686_msvc", 1157 | "windows_x86_64_gnu", 1158 | "windows_x86_64_gnullvm", 1159 | "windows_x86_64_msvc", 1160 | ] 1161 | 1162 | [[package]] 1163 | name = "windows-sys" 1164 | version = "0.45.0" 1165 | source = "registry+https://github.com/rust-lang/crates.io-index" 1166 | checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" 1167 | dependencies = [ 1168 | "windows-targets", 1169 | ] 1170 | 1171 | [[package]] 1172 | name = "windows-targets" 1173 | version = "0.42.2" 1174 | source = "registry+https://github.com/rust-lang/crates.io-index" 1175 | checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 1176 | dependencies = [ 1177 | "windows_aarch64_gnullvm", 1178 | "windows_aarch64_msvc", 1179 | "windows_i686_gnu", 1180 | "windows_i686_msvc", 1181 | "windows_x86_64_gnu", 1182 | "windows_x86_64_gnullvm", 1183 | "windows_x86_64_msvc", 1184 | ] 1185 | 1186 | [[package]] 1187 | name = "windows_aarch64_gnullvm" 1188 | version = "0.42.2" 1189 | source = "registry+https://github.com/rust-lang/crates.io-index" 1190 | checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" 1191 | 1192 | [[package]] 1193 | name = "windows_aarch64_msvc" 1194 | version = "0.42.2" 1195 | source = "registry+https://github.com/rust-lang/crates.io-index" 1196 | checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 1197 | 1198 | [[package]] 1199 | name = "windows_i686_gnu" 1200 | version = "0.42.2" 1201 | source = "registry+https://github.com/rust-lang/crates.io-index" 1202 | checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" 1203 | 1204 | [[package]] 1205 | name = "windows_i686_msvc" 1206 | version = "0.42.2" 1207 | source = "registry+https://github.com/rust-lang/crates.io-index" 1208 | checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" 1209 | 1210 | [[package]] 1211 | name = "windows_x86_64_gnu" 1212 | version = "0.42.2" 1213 | source = "registry+https://github.com/rust-lang/crates.io-index" 1214 | checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" 1215 | 1216 | [[package]] 1217 | name = "windows_x86_64_gnullvm" 1218 | version = "0.42.2" 1219 | source = "registry+https://github.com/rust-lang/crates.io-index" 1220 | checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" 1221 | 1222 | [[package]] 1223 | name = "windows_x86_64_msvc" 1224 | version = "0.42.2" 1225 | source = "registry+https://github.com/rust-lang/crates.io-index" 1226 | checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 1227 | --------------------------------------------------------------------------------