Updated highlighting
This commit is contained in:
@@ -10,7 +10,7 @@ Functions are the primary unit of execution in Mist. They prioritize a tradition
|
||||
|
||||
A standard function requires a return type, a name, and a body. Use the `void` keyword for functions that do not return a value.
|
||||
|
||||
```cpp
|
||||
```mist
|
||||
i32 add(i32 a, i32 b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ void log_status(str* message) {
|
||||
|
||||
Functions are private to their module by default. The `public` modifier exports the function for cross-module access.
|
||||
|
||||
```cpp
|
||||
```mist
|
||||
public i32 get_version() {
|
||||
return 1;
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public i32 get_version() {
|
||||
|
||||
Parameters follow Rust’s ownership rules but use Mist’s local variable syntax. Use `mut` to allow a function to modify its local binding of a value.
|
||||
|
||||
```cpp
|
||||
```mist
|
||||
void update_score(i32 mut current_score, i32 bonus) {
|
||||
current_score = current_score + bonus;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ void update_score(i32 mut current_score, i32 bonus) {
|
||||
|
||||
Mist integrates type abstraction and memory management into a single generic block. Lifetimes and type parameters share the `< >` bracket following the identifier.
|
||||
|
||||
```rust
|
||||
```mist
|
||||
public str'a* choose_longer<'a, T: Display>(str'a* s1, str'a* s2, T meta) {
|
||||
println!("Metadata: {}", meta);
|
||||
return if (s1.len() > s2.len()) { s1 } else { s2 };
|
||||
@@ -55,7 +55,7 @@ public str'a* choose_longer<'a, T: Display>(str'a* s1, str'a* s2, T meta) {
|
||||
|
||||
Metadata is applied via the `#[attr]` syntax directly above the declaration for compiler hints or testing.
|
||||
|
||||
```cpp
|
||||
```mist
|
||||
#[inline]
|
||||
public bool is_active(u32 id) {
|
||||
return id > 0;
|
||||
|
||||
Reference in New Issue
Block a user