Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Repeat/Rust/repeat-1.rust
Normal file
3
Task/Repeat/Rust/repeat-1.rust
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn repeat(f: impl FnMut(usize), n: usize) {
|
||||
(0..n).for_each(f);
|
||||
}
|
||||
3
Task/Repeat/Rust/repeat-2.rust
Normal file
3
Task/Repeat/Rust/repeat-2.rust
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
repeat(|x| print!("{};", x), 5);
|
||||
}
|
||||
7
Task/Repeat/Rust/repeat-3.rust
Normal file
7
Task/Repeat/Rust/repeat-3.rust
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fn function(x: usize) {
|
||||
print!("{};", x);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
repeat(function, 4);
|
||||
}
|
||||
10
Task/Repeat/Rust/repeat-4.rust
Normal file
10
Task/Repeat/Rust/repeat-4.rust
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
struct Foo;
|
||||
impl Foo {
|
||||
fn associated(x: usize) {
|
||||
print!("{};", x);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
repeat(Foo::associated, 8);
|
||||
}
|
||||
13
Task/Repeat/Rust/repeat-5.rust
Normal file
13
Task/Repeat/Rust/repeat-5.rust
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
trait Bar {
|
||||
fn run(self);
|
||||
}
|
||||
|
||||
impl Bar for usize {
|
||||
fn run(self) {
|
||||
print!("{};", self);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
repeat(Bar::run, 6);
|
||||
}
|
||||
11
Task/Repeat/Rust/repeat-6.rust
Normal file
11
Task/Repeat/Rust/repeat-6.rust
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fn repeat(f: impl FnMut(usize), n: usize) {
|
||||
(0..n).for_each(f);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut mult = 1;
|
||||
repeat(|x| {
|
||||
print!("{};", x * mult);
|
||||
mult += x;
|
||||
}, 5);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue