MCPcopy Create free account
hub / github.com/bedroombuilds/python2rust / double_first

Function double_first

0a_error_handling/rust/using_eyre/src/main.rs:3–7  ·  view source on GitHub ↗
(vec: Vec<&str>)

Source from the content-addressed store, hash-verified

1use eyre::{eyre, Result};
2
3fn double_first(vec: Vec<&str>) -> Result<i32> {
4 let first = vec.first().ok_or_else(|| eyre!("no first item"))?;
5 let parsed = first.parse::<i32>()?;
6 Ok(2 * parsed)
7}
8
9fn print(result: Result<i32>) {
10 match result {

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected