effers/src/lib.rs

41 lines
846 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(&self) as p), Logger(debug(self), info(&mut self)), inc::Incrementer(increment))]
fn smth(val: u8) -> u8 {
let s = p("hey hi hello");
2022-01-19 20:56:39 +00:00
info("this is a info-level log");
debug("this is a debug-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(self, s: &str);
2022-01-19 20:56:39 +00:00
fn info(&mut self, s: &str);
}
mod inc {
pub trait Incrementer {
fn increment(v: u8) -> u8;
}
}
#[program(Printer(print as p))]
fn ohter() {
let _s = p("hey hi hello");
}
2022-01-19 20:56:39 +00:00
}