mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-01-14 00:00:02 +03:00
Compare commits
10 commits
9e2ff7d037
...
981a4778a9
Author | SHA1 | Date | |
---|---|---|---|
981a4778a9 | |||
5d4363d58d | |||
48697b8225 | |||
1652bb67d9 | |||
1499f681a3 | |||
a21fa6ff40 | |||
186dc3c1ab | |||
6b7a27d080 | |||
c9017f9f7a | |||
fdada8b3d4 |
|
@ -1,7 +1,7 @@
|
||||||
# Third-Party Exercises
|
# Third-Party Exercises
|
||||||
|
|
||||||
The support of Rustlings for third-party exercises allows you to create your own set of Rustlings exercises to focus on some specific topic.
|
The support of Rustlings for third-party exercises allows you to create your own set of Rustlings exercises to focus on some specific topic.
|
||||||
You could also offer a translatation of the original Rustlings exercises as third-party exercises.
|
You could also offer a translation of the original Rustlings exercises as third-party exercises.
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Structs contain data, but can also have logic. In this exercise we have
|
// Structs contain data, but can also have logic. In this exercise, we have
|
||||||
// defined the `Package` struct and we want to test some logic attached to it.
|
// defined the `Package` struct, and we want to test some logic attached to it.
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Package {
|
struct Package {
|
||||||
|
|
|
@ -4,6 +4,7 @@ fn placeholder() {}
|
||||||
fn string_slice(arg: &str) {
|
fn string_slice(arg: &str) {
|
||||||
println!("{arg}");
|
println!("{arg}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn string(arg: String) {
|
fn string(arg: String) {
|
||||||
println!("{arg}");
|
println!("{arg}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ struct PositiveNonzeroInteger(u64);
|
||||||
impl PositiveNonzeroInteger {
|
impl PositiveNonzeroInteger {
|
||||||
fn new(value: i64) -> Result<PositiveNonzeroInteger, CreationError> {
|
fn new(value: i64) -> Result<PositiveNonzeroInteger, CreationError> {
|
||||||
match value {
|
match value {
|
||||||
0 => Err(CreationError::Zero),
|
|
||||||
x if x < 0 => Err(CreationError::Negative),
|
x if x < 0 => Err(CreationError::Negative),
|
||||||
|
0 => Err(CreationError::Zero),
|
||||||
x => Ok(PositiveNonzeroInteger(x as u64)),
|
x => Ok(PositiveNonzeroInteger(x as u64)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
fn string_slice(arg: &str) {
|
fn string_slice(arg: &str) {
|
||||||
println!("{arg}");
|
println!("{arg}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn string(arg: String) {
|
fn string(arg: String) {
|
||||||
println!("{arg}");
|
println!("{arg}");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue