mirror of
https://github.com/napi-rs/napi-rs.git
synced 2025-12-08 19:56:07 +00:00
19 lines
279 B
Rust
19 lines
279 B
Rust
#[napi]
|
|
pub struct ClassWithFactory {
|
|
pub name: String,
|
|
}
|
|
|
|
#[napi]
|
|
impl ClassWithFactory {
|
|
#[napi(factory)]
|
|
pub fn with_name(name: String) -> Self {
|
|
Self { name }
|
|
}
|
|
|
|
#[napi]
|
|
pub fn set_name(&mut self, name: String) -> &Self {
|
|
self.name = name;
|
|
self
|
|
}
|
|
}
|