solution to exercise 04_01
This commit is contained in:
parent
4a4fc2ea0d
commit
ebe07acd1e
@ -1,6 +1,6 @@
|
|||||||
fn intro() -> &'static str {
|
fn intro() -> &'static str {
|
||||||
// TODO: fix me 👇
|
// TODO: fix me 👇
|
||||||
"I'm ready to __!"
|
"I'm ready to learn about traits!"
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -3,6 +3,22 @@
|
|||||||
//
|
//
|
||||||
// Then implement the trait for `u32` and `i32`.
|
// Then implement the trait for `u32` and `i32`.
|
||||||
|
|
||||||
|
pub trait IsEven {
|
||||||
|
fn is_even(self) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IsEven for u32 {
|
||||||
|
fn is_even(self) -> bool {
|
||||||
|
self % 2 == 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IsEven for i32 {
|
||||||
|
fn is_even(self) -> bool {
|
||||||
|
self % 2 == 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user