summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2023-04-21 00:53:23 -0400
committerJohn Turner <jturner.usa@gmail.com>2023-04-21 00:53:23 -0400
commitd942f87c6168919551970f860da46b9ddd5fbea7 (patch)
tree1e33bb7a4156ac945345d9bfcd6bf118ab9aab16
parent08595d40114b8d7b38f43d2b868f66abb37fd49a (diff)
downloadget-d942f87c6168919551970f860da46b9ddd5fbea7.tar.gz
updated docs to include field hiding
-rw-r--r--src/lib.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8f6ce4b..e6a9f15 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,6 +11,9 @@
//! struct Crab {
//! name: String,
//! age: u64,
+//! // Sometimes we may not need a getter, such as on a public field.
+//! #[get(hide)]
+//! pub friend: Option<Box<Crab>>
//! }
//!
//! fn crab() {
@@ -24,7 +27,7 @@
//!
//!# impl Crab {
//!# pub fn new(name: &str, age: u64) -> Self {
-//!# Self { name: name.to_string(), age }
+//!# Self { name: name.to_string(), age, friend: None}
//!# }
//!# }
//!```
@@ -77,10 +80,18 @@
//!# }
//!```
//! # Attributes
+//! Attributes are expected to contain a comma separated list of name value pairs or idents.
//!
-//! The following name value pairs are supported in attributes:
+//! Examples of supported attributes:
//! * `#[get(method = "getter")]`
+//! * `#[get(hide)]`
//!
+//! All supported name value pairs:
+//! * `method` (this sets the name of the getter method)
+//!
+//! All supported idents are:
+//! * `hide` (this will disable getters for a specific field)
+
#[proc_macro_derive(Get, attributes(get))]
pub fn get(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let parsed_input = syn::parse_macro_input!(input as syn::DeriveInput);