effers/src/lib.rs

42 lines
890 B
Rust
Raw Normal View History

2022-01-19 20:56:39 +00:00
pub use effers_derive::program;
#[cfg(test)]
mod test {
use super::*;
#[program(Smth => Printer(print as p), Logger(mut debug, mut info), inc::Incrementer(mut increment))]
fn smth(val: u8) -> u8 {
let s = p("hey hi hello");
2022-01-19 20:56:39 +00:00
debug("this is a debug-level log");
info("this is a info-level log");
2022-01-19 20:56:39 +00:00
let _s = p("hey hi hello");
dbg!(s);
let x = increment(val);
let y = increment(x);
x + y
}
2022-01-19 20:56:39 +00:00
trait Printer {
fn print(&self, s: &str) -> &str;
2022-01-19 20:56:39 +00:00
}
trait Logger {
fn debug(&mut self, s: &str);
fn info(&mut self, s: &str);
}
mod inc {
pub trait Incrementer {
fn increment(&mut self, v: u8) -> u8;
}
}
// TODO make nameless programs work
#[program(Printer(print as p))]
fn ohter() {
let _s = p("hey hi hello");
}
2022-01-19 20:56:39 +00:00
}