10 个版本 (4 个重大更新)
0.7.1 | 2022 年 10 月 22 日 |
---|---|
0.7.0 | 2022 年 10 月 22 日 |
0.6.2 | 2022 年 10 月 21 日 |
0.5.1 | 2022 年 10 月 21 日 |
0.1.0 |
|
在 过程宏 中排名 1400
每月下载量 41 次
345KB
5.5K SLoC
auto_impl_trait
#[auto_impl_trait("./src/rect_trait.rs", Rect, "runtime")]
#[doc = "Test this will keep after expand"]
#[derive(Debug)]
struct Square {
side: i32,
}
将扩展为
mod item;
mod area;
mod perimeter;
mod scale;
mod ____CGQAQ__SUPER_TRAIT____ {
pub mod runtime {
use std::ops::{Add, Sub, Mul, Div};
pub trait Rect {
type Item: Add + Sub + Mul + Div;
fn area(&self) -> Self::Item;
fn perimeter(&self) -> Self::Item;
fn scale(&mut self, scale: Self::Item);
}
}
pub use runtime::Rect;
}
pub mod __Rect_area__ {
pub type Item = super::item::Item;
#[tonic::async_trait]
pub trait __Rect_area__ { fn area(&self) -> Item; }
}
pub mod __Rect_perimeter__ {
pub type Item = super::item::Item;
#[tonic::async_trait]
pub trait __Rect_perimeter__ { fn perimeter(&self) -> Item; }
}
pub mod __Rect_scale__ {
pub type Item = super::item::Item;
#[tonic::async_trait]
pub trait __Rect_scale__ { fn scale(&mut self, scale: Item); }
}
use ____CGQAQ__SUPER_TRAIT____::Rect;
#[doc = "Test this will keep after expand"]
#[derive(Debug)]
struct Square {
side: i32,
}
#[tonic::async_trait]
impl Rect for Square {
type Item = super::item::Item;
fn area(&self) -> Self::Item { <dyn __Rect_area__::__Rect_area__>::area(self) }
fn perimeter(&self) -> Self::Item { <dyn __Rect_perimeter__::__Rect_perimeter__>::perimeter(self) }
fn scale(&mut self, scale: Self::Item) { <dyn __Rect_scale__::__Rect_scale__>::scale(self, scale) }
}
依赖项
~8–11MB
~187K SLoC