As a beginner in Rust, I’m sure you’ll be as shocked as I was by the complexity of its grammar

The code below looks like a combination of Java and JavaScript

use std::io::prelude::*; use std::fs::OpenOptions; fn main() -> std::io::Result<()> { let mut file = OpenOptions::new() .append(true).open("D:\\text.txt")? ; file.write(b" APPEND WORD")? ; Ok(()) }
fn main() { let mut v = vec! [1, 2, 4, 8]. println! ("{}", match v.get(0) { Some(value) => value.to_string(), None => "None".to_string() }); }

about= >The use of the

As a new language, only 6 years old, Rust has absorbed a lot of syntax from high-level languages like JS, Java, Python and so on

=> < span style = “font-size: 14px! Important;

In rust, => is “the part that matches the prepared syntax.”

In plain English, when using the match statement, each different case is matched, and if the match is successful, the corresponding code following the => symbol is executed.

Arrow functions are a must for JavaScript beginners

about->The use of the

-> indicates the return type of the function

Just like type annotations in Python

fn max(array: &[i32]) -> i32 { let mut max_index = 0; let mut i = 1; while i < array.len() { if array[i] > array[max_index] { max_index = i; } i += 1; } return array[max_index]; } fn main() { let a = [2, 4, 6, 3, 1]; println! ("max = {}", max(&a)); }