mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2024-11-09 08:51:18 +08:00
parent
693598b0fd
commit
6caa81b4ec
@ -1,11 +1,21 @@
|
|||||||
|
pub fn add(left: usize, right: usize) -> usize {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
// ANCHOR: here
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() -> Result<(), String> {
|
fn it_works() -> Result<(), String> {
|
||||||
if 2 + 2 == 4 {
|
let result = add(2, 2);
|
||||||
|
|
||||||
|
if result == 4 {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(String::from("two plus two does not equal four"))
|
Err(String::from("two plus two does not equal four"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ANCHOR_END: here
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user