Add compound assignment operators (+=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=) and shift operators (<<, >>) to the tmLanguage syntax highlighting grammar. Patterns are ordered longest-first to prevent shorter tokens from shadowing multi-character operators. Also update fibonacci example to use += compound assignment.
23 lines
358 B
Plaintext
23 lines
358 B
Plaintext
fn fibonacci_rec(n: u8) -> u64 {
|
|
if n < 2 {
|
|
return n;
|
|
}
|
|
|
|
return fibonacci_rec(n - 1) + fibonacci_rec(n - 2);
|
|
}
|
|
|
|
fn fibonacci_iter(n: u8) -> u64 {
|
|
let mut counter = 0;
|
|
let mut a = 0;
|
|
let mut b = 1;
|
|
|
|
while counter < n {
|
|
let temp = a + b;
|
|
a = b;
|
|
b = temp;
|
|
|
|
counter += 1;
|
|
}
|
|
|
|
return a;
|
|
} |