Improved last two features
This commit is contained in:
+41
-12
@@ -44,27 +44,56 @@ void process_data() {
|
|||||||
title: "Class and Type System",
|
title: "Class and Type System",
|
||||||
description:
|
description:
|
||||||
"Classes are syntactic sugar for Rust structs. Using 'extends' provides inheritance-style syntax over struct composition, compiling into the underlying Rust type system.",
|
"Classes are syntactic sugar for Rust structs. Using 'extends' provides inheritance-style syntax over struct composition, compiling into the underlying Rust type system.",
|
||||||
code: `public class Entity {
|
code: `public struct PluginInfo {
|
||||||
u32 id;
|
public String name,
|
||||||
|
public String version,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compiles to struct composition in Rust
|
public class PluginRegistry<T> {
|
||||||
public struct Player extends Entity {
|
T plugins;
|
||||||
String username;
|
|
||||||
|
|
||||||
public constructor(u32 id, str* name) {
|
public constructor(T plugins) {
|
||||||
self.id = id;
|
self.plugins = plugins;
|
||||||
self.username = name.to_string();
|
}
|
||||||
|
|
||||||
|
public T plugins(self) {
|
||||||
|
return self.plugins;
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
title: "Explicit Mutability",
|
title: "Better Developer Experience",
|
||||||
description:
|
description:
|
||||||
"Mist maintains memory intent through explicit self pointers and mutability modifiers.",
|
"While Rust can already be a great DX, Mist implements concepts that are proven to improve structure.",
|
||||||
code: `public void update_id(self mut*, u32 new_id) {
|
code: `public class Logger {
|
||||||
self.id = new_id;
|
String prefix;
|
||||||
|
|
||||||
|
public constructor(str* prefix) {
|
||||||
|
self.prefix = prefix.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(self*, LogLevel level, str* message) {
|
||||||
|
match(level) {
|
||||||
|
LogLevel::Info => {
|
||||||
|
println!("{level} {} {}", self.prefix, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogLevel::Warning => {
|
||||||
|
println!("{level} {} {}", self.prefix, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogLevel::Error => {
|
||||||
|
println!("{level} {} {}", self.prefix, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display {
|
||||||
|
fmt::Result fmt(self*, std::fmt::Formatter<'_> mut* f) {
|
||||||
|
return write!(f, "logger ({})", self.prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user