Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #[inline] attribute to a few more methods #334

Merged
merged 2 commits into from Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -69,6 +69,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
([#298](https://github.com/JelteF/derive_more/pull/298))
- Add `TryFrom` derive for enums to convert from their discriminant.
([#300](https://github.com/JelteF/derive_more/pull/300))
- `#[inline]` attributes to `IsVariant` and `Debug` implementations.
([#334](https://github.com/JelteF/derive_more/pull/334)

### Changed

Expand Down
4 changes: 4 additions & 0 deletions impl/src/error.rs
Expand Up @@ -37,6 +37,8 @@ pub fn expand(
};

let source = source.map(|source| {
// Not using `#[inline]` here on purpose, since this is almost never part
// of a hot codepath.
quote! {
fn source(&self) -> Option<&(dyn ::derive_more::Error + 'static)> {
use ::derive_more::__private::AsDynError;
Expand All @@ -46,6 +48,8 @@ pub fn expand(
});

let provide = provide.map(|provide| {
// Not using `#[inline]` here on purpose, since this is almost never part
// of a hot codepath.
quote! {
fn provide<'_request>(&'_request self, request: &mut ::derive_more::core::error::Request<'_request>) {
#provide
Expand Down
1 change: 1 addition & 0 deletions impl/src/fmt/debug.rs
Expand Up @@ -47,6 +47,7 @@ pub fn expand(input: &syn::DeriveInput, _: &str) -> syn::Result<TokenStream> {
Ok(quote! {
#[automatically_derived]
impl #impl_gens ::derive_more::Debug for #ident #ty_gens #where_clause {
#[inline]
fn fmt(
&self, __derive_more_f: &mut ::derive_more::core::fmt::Formatter<'_>
) -> ::derive_more::core::fmt::Result {
Expand Down
1 change: 1 addition & 0 deletions impl/src/is_variant.rs
Expand Up @@ -44,6 +44,7 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
#[doc = "Returns `true` if this value is of type `"]
#[doc = #variant_name]
#[doc = "`. Returns `false` otherwise"]
#[inline]
pub const fn #fn_name(&self) -> bool {
match self {
#enum_name ::#variant_ident #data_pattern => true,
Expand Down