Crates.io | zyc_getset |
lib.rs | zyc_getset |
version | 0.0.1 |
source | src |
created_at | 2024-12-05 10:43:47.633702 |
updated_at | 2024-12-05 11:16:28.370862 |
description | For personal projects using this crate, it is recommended to stick with the original getset crate. As an extension to the original crate, we've introduced a new method: get_clone. Methods without an explicit visibility specifier are automatically declared as pub. This is a conscious design choice, as internal methods typically don't necessitate getset mechanisms. |
homepage | |
repository | https://github.com/jbaublitz/getset |
max_upload_size | |
id | 1473069 |
size | 50,902 |
For personal projects using this crate, it is recommended to stick with the original getset 0.1.3
(https://crates.io/crates/getset) crate.
As an extension to the original crate, we've introduced a new method: get_clone.
Methods without an explicit visibility specifier are automatically declared as pub. This is a conscious design choice, as internal methods typically don't necessitate getset mechanisms.
#[derive(Getters, CloneGetters)]
pub struct Foo {
#[get]
id: i32,
#[get_clone]
name: String,
}
use zyc_getset::Getters;
pub struct Foo {
#[get]
id: i32,
#[get_clone]
name: String,
}
impl Foo {
#[inline(always)]
pub fn id(&self) -> &i32 {
&self.id
}
}
impl Foo {
#[inline(always)]
pub fn name(&self) -> String { // default pub
self.name.clone() // add clone
}
}