Skip to content

Rust macro that makes multiple items or fields public at once

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

lefebvreb/fully_pub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fully Pub

github crates.io docs.rs

This crate exposes a single attribute macro that can be used to alleviate some of the verbosity of marking every field of a Rust item as pub, by doing it automatically.

[dependencies]
fully_pub = "0.1"

Example

use fully_pub::fully_pub;

#[fully_pub]
struct User {
    name: String,
    age: i32,
    #[fully_pub(exclude)]
    secret: String,
}

#[fully_pub]
impl User {
    fn new(name: String, age: i32, secret: String) -> Self {
        Self { name, age, secret }
    }

    fn happy_birthday(&mut self) {
        self.age += 1;
    }

    #[fully_pub(exclude)]
    fn get_secret(&mut self) -> &str {
        &self.secret
    }
}

This macro works on nearly everything in the Rust programming language, and can even be used on nested modules recursively, if needed.

See the documentation of the macro itself for more details.


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Rust macro that makes multiple items or fields public at once

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages