## Usage:
Add this to your Cargo.toml:
```toml
[dependencies]
copy_impl = "0.3.3"
```
and this to your source code:
```rust
use copy_impl::copy_impl;
```
## Example:
```rust
use std::{error::Error, fmt::Write};
use copy_impl::copy_impl;
struct CustomNum(T);
struct UncheckedCustomNum(T);
copy_impl! {
impl (CustomNum),
impl (CustomNum),
impl (CustomNum),
impl (UncheckedCustomNum),
impl (UncheckedCustomNum) {
pub fn write_to(&self, mut w: impl Write) -> Result<(), std::fmt::Error> {
write!(w, "{}", self.0)
}
}
}
fn main() -> Result<(), Box> {
let mut tbuff = String::new();
CustomNum(1i8).write_to(&mut tbuff)?;
CustomNum(2i16).write_to(&mut tbuff)?;
CustomNum(3i32).write_to(&mut tbuff)?;
UncheckedCustomNum(4i8).write_to(&mut tbuff)?;
UncheckedCustomNum(5i16).write_to(&mut tbuff)?;
// UncheckedCustomNum(6i32).write_to(&mut tbuff)?;
/*
no method named `write_to` found for struct `UncheckedCustomNum` in the current scope
the method was found for
- `UncheckedCustomNum`
- `UncheckedCustomNum`
*/
assert_eq!(tbuff, "12345");
Ok(())
}
```
See all
## License:
This project has a dual license according to (LICENSE-MIT) and (LICENSE-APACHE-2-0).
Copyright (c) 2021-2024 #UlinProject (Denis Kotlyarov).
### Apache License:
Licensed under the Apache License, Version 2.0.
### MIT License:
Licensed under the MIT License.