Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn check_sum(v: Vec<i32>) -> Result<i32, String> {
- if v.is_empty() {
- return Err("Empty vec!".into());
- }
- let mut sum = 0;
- for i in v {
- sum += i;
- }
- return Ok(sum);
- }
- fn main() {
- let v = Vec::new();
- check_sum(v).expect("Got an error");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement