MCPcopy Create free account
hub / github.com/Apress/beginning-rust-2e / incremented

Function incremented

Source Code/17-15.rs:6–9  ·  view source on GitHub ↗
(n: i32)

Source from the content-addressed store, hash-verified

4*/
5fn main() -> Result<(), String> {
6 fn incremented(n: i32) -> Result<i32, String> {
7 if n < 0 { Err(format!("negative argument")) }
8 else { Ok(n + 1) }
9 }
10 println!("{} ", incremented(4)?);
11 println!("{} ", incremented(-3)?);
12 println!("{} ", incremented(7)?);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected