我有一个代码转储,我在其中放置了防锈代码示例,以防我忘记了什么.我一直在error: expected item, found 'let'寻找41+线.可能是我的代码结构不正确吗?我只是将我学到的代码片段粘贴到main.rs中.我认为枚举有某种特殊的格式或地方.
我试着更改名称,认为这是名称惯例; 但这没有帮助.同样的错误.
这是转储(实际上并不大)
#[allow(dead_code)]
fn main()
{
}
/////////////////////////////////////////tutorial functoins i made
fn if_statements()
{
//let (x, y) = (5, 10);
let x = 5;
let y = if x == 5 { 10 } else { 15 };
if y == 15 {println!("y = {}", y);}
}
////////////////////////////////////////// tutoiral functions
#[allow(dead_code)]
fn add(a: i32, b: i32) -> i32
{
a + b
}
#[allow(dead_code)]
fn crash(exception: &str) -> !
{
panic!("{}", exception); …Run Code Online (Sandbox Code Playgroud) rust ×1