Impl spanned functions

This commit is contained in:
2026-05-19 06:11:52 +02:00
parent fd7455c71e
commit 9d051c68e9
2 changed files with 9 additions and 3 deletions
+8 -2
View File
@@ -2,7 +2,7 @@ use <std::fmt::Formatter>;
use <std::fmt>; use <std::fmt>;
pub trait TestLogging<T: fmt::Display>: fmt::Display { pub trait TestLogging<T: fmt::Display>: fmt::Display {
String get(); String get(self*);
} }
pub enum LogLevel { pub enum LogLevel {
@@ -29,6 +29,12 @@ impl fmt::Display for LogLevel {
} }
} }
impl TestLogging<LogLevel> for LogLevel {
String get(self*) {
return format!("{self}");
}
}
pub class Logger { pub class Logger {
String prefix; String prefix;
@@ -55,7 +61,7 @@ pub class Logger {
} }
LogLevel::Warning => { LogLevel::Warning => {
println!("{level} {} {}", self.prefix, message); println!("{} {} {}", level.get(), self.prefix, message);
} }
LogLevel::Error => { LogLevel::Error => {
+1 -1
View File
@@ -105,7 +105,7 @@ pub struct ImplDecl {
pub generics: GenericsDecl, pub generics: GenericsDecl,
pub target: TypeExpr, pub target: TypeExpr,
pub trait_: Option<TypeExpr>, pub trait_: Option<TypeExpr>,
pub methods: Vec<FunctionDecl>, pub methods: Vec<Spanned<FunctionDecl>>,
} }
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]