Updated highlighting
This commit is contained in:
@@ -10,7 +10,7 @@ Classes in Mist bridge the gap between Java's organizational structure and Rust'
|
||||
|
||||
A class groups fields and methods together. Fields follow the `type name` convention, and methods define their logic directly within the class body.
|
||||
|
||||
```cpp
|
||||
```mist
|
||||
public class Logger {
|
||||
String prefix;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Logger {
|
||||
|
||||
Unlike languages that use the class name for initialization, Mist uses the explicit `constructor` keyword. This makes the entry point of the class unmistakable.
|
||||
|
||||
```cpp
|
||||
```mist
|
||||
public constructor(str* prefix) {
|
||||
self.prefix = prefix.to_string();
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public constructor(str* prefix) {
|
||||
|
||||
Mist maintains Rust's explicit context handling. Any method that needs to access or modify class data must include `self*` (or `self mut*` for mutations) as its first parameter.
|
||||
|
||||
```cpp
|
||||
```mist
|
||||
public void warning(self*, str* message) {
|
||||
self.log(LogLevel::Warning, message);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public void warning(self*, str* message) {
|
||||
|
||||
One of Mist's most powerful features is the ability to nest trait implementations directly within the class block. This keeps the logic for how a type behaves (e.g., how it is displayed) physically coupled with the type definition.
|
||||
|
||||
```cpp
|
||||
```mist
|
||||
impl fmt::Display {
|
||||
std::fmt::Result fmt(self*, std::fmt::Formatter<'_> mut* f) {
|
||||
return write!(f, "logger ({})", self.prefix);
|
||||
|
||||
Reference in New Issue
Block a user