Closed
Description
pub fn nth(n:u32)->Option<u32>{
let mut x:u32 = 2;
let mut m:u32 = 1;
let mut p:Vec<u32> = vec![2];
'outer: loop {
x += 1;
'inner: for i in p.iter() {
if x % i ==0{
continue 'outer;
}
}
p.push(x);
m+=1;
if n < 1 {
return None;
} else if n == 1 {
return Some(2);
} else m == n { // should be else if here
return Some(x);
}
}
}
fn main(){
println!("{:?}", nth(1));
}
The error here is if is missing in else if
but compiler reports: error:
error: expected identifier, found keyword `return`
--> src/main.rs:19:13
|
19 | return Some(x);
| ^^^^^^