-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,109 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,13 +22,18 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | |
### Main repos | ||
|
||
- [this repo](https://github.com/djnzx/rust-course) | ||
- [this repo]([email protected]:djnzx/rust-course.git) | ||
- [main sandbox](https://github.com/djnzx/learning-rust) | ||
- [main sandbox]([email protected]:djnzx/learning-rust.git) | ||
- [tasks for students solved](https://github.com/djnzx/rust-tasks-solved) | ||
- [tasks for students solved]([email protected]:djnzx/rust-tasks-solved.git) | ||
|
||
### Templates | ||
|
||
- [simple Rust template](https://github.com/djnzx/rust-template) | ||
- [simple Rust template]([email protected]:djnzx/rust-template.git) | ||
- [main template for 2xx groups](https://github.com/djnzx/rust-2xx-practice) | ||
- [main template for 2xx groups]([email protected]:djnzx/rust-2xx-practice.git) | ||
- [yet another template (223on)](https://github.com/djnzx/rust-223) | ||
- [yet another template (221on)](https://github.com/djnzx/rust-221on) | ||
- [yet another template (222on)](https://github.com/djnzx/rust-222on) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
### System Programming. Rust. I semester | ||
|
||
1. Примітивні Типи. цілочисельні: u32/i32, розмір типів в байтах. | ||
2. Примітивні Типи. кодування float. точність. Максимальне число без втрати точності. | ||
3. Примітивні Типи. char, isize, usize, кодування від'ємних чисел. | ||
4. Масиви. Декларація, використання, переваги, недоліки. | ||
5. Масиви. Чи може масив зберігати різні дані. | ||
6. Масиви. Slices. Синтаксис. Переваги використання. | ||
7. String. Char. Encodings. Скільки байтів займає символ в String, чому. ASCII, UTF8. | ||
8. String. Char. Encodings. Чи можна модифікувати String. mutable/immutable | ||
9. String. Char. Encodings. Як зрозуміти чи можна різати String в місці який нам потрібно | ||
10. Композитні типи. Tuple, Unit. Які значення має тип Unit | ||
11. Композитні типи. Named Tuple (Tuple Struct), Unit. | ||
12. Композитні типи. Struct, Unit. | ||
13. Композитні типи. Enum. Для чого. Переваги, недоліки. | ||
14. Композитні типи. Enum. Практичні приклади. | ||
15. Композитні типи. Enum. Що таке exhaustiveness check. | ||
16. Патерн матчінг. Для чого використовується, як виглядає else. | ||
17. Патерн матчінг. Обмеження | ||
18. Патерн матчінг. Практичні приклади. exhaustiveness check. | ||
19. Управління виконанням. if, else, match, | ||
20. Управління виконанням. Булева алгебра. Операції NOT, AND, OR, XOR, => | ||
21. Управління виконанням. loop, while, for, break, continue | ||
22. Функції, замакиння, різниця, плюси, мінуси, обмеження. | ||
23. Функції, замакиння. Unit, implicit Unit, explicit Unit. Які значення має тип Unit | ||
24. Функції, замакиння. | ||
25. Impl блок. Функції, Асоційовані функції, self, &self, Self. | ||
26. Traits. використання | ||
27. Використання Traits для створення власного синтаксису | ||
28. Iterators. Концепція, основні методи, переваги. Чи можна використовувати ітератор більш як 1 раз. | ||
29. Iterators. Концепція, методи роботи з даними: map, filter, flat_map, zip, ... | ||
30. Iterators. Концепція, методи для закінчення ітерації: for_each, collect, all, any, count, sum | ||
31. Використання _ в мові програмування Rust. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
### exam questions | ||
### exam questions from rust by practice | ||
|
||
- fizzbuzz | ||
- envelope | ||
|
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Лекція 16. Контрольне опитування | ||
|
||
### Скільки разів можна використовувати вже створений ітератор? | ||
|
||
- безліч | ||
- 1 | ||
- скільки потрібно | ||
- 2 | ||
- не знаю | ||
- в залежності від реалізації | ||
- що таке ітератор | ||
|
||
### Чи можливо створити ітератор який ніколи не закінчується? | ||
|
||
- так | ||
- ні | ||
- не знаю | ||
- в залежності від ситуації |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
### the simplest tasks on Hackerrank.com | ||
|
||
- https://www.hackerrank.com/challenges/simple-array-sum/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/compare-the-triplets/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/a-very-big-sum/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/diagonal-difference?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/plus-minus/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/staircase/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/mini-max-sum/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/birthday-cake-candles/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/time-conversion/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/grading/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/apple-and-orange/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/kangaroo/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/between-two-sets/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/the-birthday-bar/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/divisible-sum-pairs?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/migratory-birds/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/bon-appetit/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/sock-merchant/problem?isFullScreen=true | ||
- https://www.hackerrank.com/challenges/drawing-book/problem?isFullScreen=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
trait Iterator { | ||
type Item; | ||
fn next(&mut self) -> Option<Self::Item>; | ||
} | ||
|
||
enum Option<A> { | ||
Some(A), | ||
None, | ||
} | ||
|
||
// fn a() { | ||
// let x = null; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::slice::Iter; | ||
|
||
#[test] | ||
fn test1() { | ||
let xs = [1, 2, 3]; | ||
|
||
for x in xs { | ||
println!("{}", x); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test() { | ||
let xs = [1, 2, 3]; | ||
let it: Iter<i32> = xs.iter(); | ||
|
||
for x in it { | ||
println!("{}", x); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
struct Months { | ||
months: Vec<String>, | ||
} | ||
|
||
struct MonthsIterator<'a> { | ||
months: &'a Vec<String>, | ||
current: usize, | ||
} | ||
|
||
impl Months { | ||
fn iter(&self) -> MonthsIterator { | ||
MonthsIterator { | ||
months: &self.months, | ||
current: 0, | ||
} | ||
} | ||
|
||
pub fn winter() -> Months { | ||
Months { | ||
months: vec![ | ||
"December".to_string(), | ||
"January".to_string(), | ||
"February".to_string(), | ||
], | ||
} | ||
} | ||
|
||
pub fn new() -> Months { | ||
Months { | ||
months: vec![ | ||
"January".to_string(), | ||
"February".to_string(), | ||
"March".to_string(), | ||
"April".to_string(), | ||
"May".to_string(), | ||
"June".to_string(), | ||
"July".to_string(), | ||
"August".to_string(), | ||
"September".to_string(), | ||
"October".to_string(), | ||
"November".to_string(), | ||
"December".to_string(), | ||
], | ||
} | ||
} | ||
} | ||
|
||
impl Iterator for MonthsIterator<'_> { | ||
type Item = String; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
if self.current < self.months.len() { | ||
let x = Some(self.months[self.current].clone()); | ||
self.current += 1; | ||
x | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
|
||
#[test] | ||
fn test1() { | ||
let mm = Months::new(); | ||
for x in mm.iter() { | ||
println!("{}", x); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test2() { | ||
let mm = Months::new(); | ||
let it = mm.iter(); | ||
|
||
let it = it.filter(|x| x.starts_with("J")); | ||
|
||
it.for_each(|x| println!("{}", x)); | ||
|
||
// .take(1) | ||
// .for_each(|x| println!("{}", x)); | ||
} | ||
|
||
#[test] | ||
fn test3() { | ||
let mm = Months::winter(); | ||
|
||
for m in mm.iter() { | ||
println!("{}", m); | ||
} | ||
|
||
for m in mm.iter() { | ||
println!("{}", m); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test4() { | ||
let mm = Months::winter(); | ||
mm.iter() | ||
.for_each(|x| println!("{}", x)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
struct Months { | ||
months: Vec<String>, | ||
current: usize, | ||
} | ||
|
||
impl Months { | ||
pub fn winter() -> Months { | ||
Months { | ||
months: vec![ | ||
"December".to_string(), | ||
"January".to_string(), | ||
"February".to_string(), | ||
], | ||
current: 0, | ||
} | ||
} | ||
|
||
pub fn new() -> Months { | ||
Months { | ||
months: vec![ | ||
"January".to_string(), | ||
"February".to_string(), | ||
"March".to_string(), | ||
"April".to_string(), | ||
"May".to_string(), | ||
"June".to_string(), | ||
"July".to_string(), | ||
"August".to_string(), | ||
"September".to_string(), | ||
"October".to_string(), | ||
"November".to_string(), | ||
"December".to_string(), | ||
], | ||
current: 0, | ||
} | ||
} | ||
} | ||
|
||
impl Iterator for Months { | ||
type Item = String; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
if self.current < self.months.len() { | ||
let x = Some(self.months[self.current].clone()); | ||
self.current += 1; | ||
x | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
|
||
#[test] | ||
fn test1() { | ||
let mm = Months::new(); | ||
for x in mm { | ||
println!("{}", x); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test2() { | ||
let mm = Months::new(); | ||
mm.take(1) | ||
.for_each(|x| println!("{}", x)); | ||
} | ||
|
||
#[test] | ||
fn test3() { | ||
let mm = Months::winter(); | ||
|
||
for m in mm { | ||
println!("{}", m); | ||
} | ||
|
||
// for m in mm { | ||
// println!("{}", m); | ||
// } | ||
} | ||
|
||
#[test] | ||
fn test4() { | ||
let mm = Months::winter(); | ||
mm.for_each(|x| println!("{}", x)); | ||
} |
Oops, something went wrong.