Fmt Allman style

This commit is contained in:
2026-06-26 01:49:00 +02:00
parent 6c9c0e03d2
commit 9b7de09b0a
10 changed files with 178 additions and 96 deletions
+28 -17
View File
@@ -1,55 +1,66 @@
pub module class_test;
pub class Animal {
pub class Animal
{
pub String name;
constructor() {
constructor()
{
self.name = "Rex".to_string();
}
pub String speak(&self) {
pub String speak(&self)
{
"Unknown".to_string()
}
pub void test_speak<'a>(&'a self) {
pub void test_speak<'a>(&'a self)
{
assert_eq!(self.speak(), "Woof!");
}
pub void static_method() {
pub void static_method()
{
}
}
pub class Mammal : Animal {
constructor() {
pub class Mammal : Animal
{
constructor()
{
super = Super::new();
}
pub void args_test(&self, i32 x, str& y) {
pub void args_test(&self, i32 x, str& y)
{
assert_eq!(x, 10);
assert_eq!(y, "hello");
}
}
pub class Dog : Mammal {
constructor() {
pub class Dog : Mammal
{
constructor()
{
super = Super::new();
}
pub String speak(&self) override(Animal) {
pub String speak(&self) override(Animal)
{
"Woof!".to_string()
}
impl std::fmt::Display {
Result<(), std::fmt::Error> fmt(&self, std::fmt::Formatter<'_>& mut f) {
impl std::fmt::Display
{
Result<(), std::fmt::Error> fmt(&self, std::fmt::Formatter<'_>& mut f)
{
write!(f, "🐾 {}", self.name)
}
}
}
pub void run_tests() {
pub void run_tests()
{
let dawg = Dog::new();
dawg.args_test(10, "hello");
dawg.test_speak();