5个版本 (稳定)
2.1.0 | 2023年8月15日 |
---|---|
2.0.1 | 2023年8月15日 |
1.0.0 | 2023年7月7日 |
0.1.0 | 2023年7月7日 |
#8 在 #deref-mut
215 每月下载次数
在 2 crates 中使用
10KB
112 行
derived-deref
一个用于从具有至少一个字段的struct派生标准库中的Deref
和DerefMut
特质的Crate。具有引用的字段将直接传递。
示例
use derived_deref::{Deref, DerefMut};
#[derive(Deref, DerefMut)]
struct StringWithCount {
// Annotation of `#[target]` is required when there are two+ fields.
#[target] inner: String,
count: usize,
}
// When there is only one field, annotation is optional instead.
#[derive(Deref, DerefMut)]
struct StringWrapper(String);
#[derive(Deref, DerefMut)]
struct CountWrapper(#[target] usize);
lib.rs
:
一个用于从具有至少一个字段的struct派生标准库中的Deref
和DerefMut
特质的Crate。具有引用的字段将直接传递。
示例
use derived_deref::{Deref, DerefMut};
#[derive(Deref, DerefMut)]
struct StringWithCount {
// Annotation of `#[target]` is required when there are two+ fields.
#[target] inner: String,
count: usize,
}
// When there is only one field, annotation is optional instead.
#[derive(Deref, DerefMut)]
struct StringWrapper(String);
#[derive(Deref, DerefMut)]
struct CountWrapper(#[target] usize);
依赖
~265–710KB
~17K SLoC