Skip to content

Commit

Permalink
Merge 62bc31b into ad232bf
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverbear committed Nov 16, 2019
2 parents ad232bf + 62bc31b commit 47d839e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -54,6 +54,7 @@ where
/// Doc comments are supported!
/// Multiline, even.
#[inline(always)]
#[must_use]
fn private(&self) -> &T {
&self.private
}
Expand Down Expand Up @@ -84,12 +85,14 @@ where
/// Doc comments are supported!
/// Multiline, even.
#[inline(always)]
#[must_use]
fn private_mut(&mut self) -> &mut T {
&mut self.private
}
/// Doc comments are supported!
/// Multiline, even.
#[inline(always)]
#[must_use]
pub fn public_mut(&mut self) -> &mut T {
&mut self.public
}
Expand All @@ -101,6 +104,7 @@ where
/// Doc comments are supported!
/// Multiline, even.
#[inline(always)]
#[must_use]
pub fn public(&self) -> T {
self.public
}
Expand Down
3 changes: 3 additions & 0 deletions src/generate.rs
Expand Up @@ -125,6 +125,7 @@ pub fn implement(field: &Field, mode: &GenMode, params: &GenParams) -> TokenStre
quote! {
#(#doc)*
#[inline(always)]
#[must_use]
#visibility fn #fn_name(&self) -> &#ty {
&self.#field_name
}
Expand All @@ -134,6 +135,7 @@ pub fn implement(field: &Field, mode: &GenMode, params: &GenParams) -> TokenStre
quote! {
#(#doc)*
#[inline(always)]
#[must_use]
#visibility fn #fn_name(&self) -> #ty {
self.#field_name
}
Expand All @@ -153,6 +155,7 @@ pub fn implement(field: &Field, mode: &GenMode, params: &GenParams) -> TokenStre
quote! {
#(#doc)*
#[inline(always)]
#[must_use]
#visibility fn #fn_name(&mut self) -> &mut #ty {
&mut self.#field_name
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Expand Up @@ -48,6 +48,7 @@ where
/// Doc comments are supported!
/// Multiline, even.
#[inline(always)]
#[must_use]
fn private(&self) -> &T {
&self.private
}
Expand Down Expand Up @@ -78,12 +79,14 @@ where
/// Doc comments are supported!
/// Multiline, even.
#[inline(always)]
#[must_use]
fn private_mut(&mut self) -> &mut T {
&mut self.private
}
/// Doc comments are supported!
/// Multiline, even.
#[inline(always)]
#[must_use]
pub fn public_mut(&mut self) -> &mut T {
&mut self.public
}
Expand All @@ -95,6 +98,7 @@ where
/// Doc comments are supported!
/// Multiline, even.
#[inline(always)]
#[must_use]
pub fn public(&self) -> T {
self.public
}
Expand Down
6 changes: 3 additions & 3 deletions tests/copy_getters.rs
Expand Up @@ -101,19 +101,19 @@ mod submodule {
#[test]
fn test_plain() {
let val = Plain::default();
val.private_accessible();
let _ = val.private_accessible();
}

#[test]
fn test_generic() {
let val = Generic::<usize>::default();
val.private_accessible();
let _ = val.private_accessible();
}

#[test]
fn test_where() {
let val = Where::<usize>::default();
val.private_accessible();
let _ = val.private_accessible();
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions tests/getters.rs
Expand Up @@ -101,19 +101,19 @@ mod submodule {
#[test]
fn test_plain() {
let val = Plain::default();
val.private_accessible();
let _ = val.private_accessible();
}

#[test]
fn test_generic() {
let val = Generic::<usize>::default();
val.private_accessible();
let _ = val.private_accessible();
}

#[test]
fn test_where() {
let val = Where::<usize>::default();
val.private_accessible();
let _ = val.private_accessible();
}

#[test]
Expand Down

0 comments on commit 47d839e

Please sign in to comment.