Skip to content

Commit

Permalink
Return derive module
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Sep 9, 2024
1 parent 4e2d175 commit fd1d3f3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ trait will be in scope when you add the following code:
use derive_more::with_trait::Display; // also imports `core::fmt::Display`
```

By default, derive macros only, without the corresponding traits, are import from
the crate's root:
By default, derive macros only, without the corresponding traits, are imported from
the crate's root (or from the `derive` module):
```rust
use derive_more::Display; // imports macro only
use derive_more::Display; // imports macro only
use derive_more::derive::*; // imports all macros only
```

#### Hygiene
Expand Down
3 changes: 2 additions & 1 deletion impl/src/try_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ impl ToTokens for Expansion {

quote! {
#[automatically_derived]
impl #impl_generics derive_more::core::convert::TryFrom<#repr_ty #ty_generics> for #ident #where_clause {
impl #impl_generics derive_more::core::convert::TryFrom<#repr_ty #ty_generics>
for #ident #where_clause {
type Error = #error;

#[allow(non_upper_case_globals)]
Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ pub use crate::try_unwrap::TryUnwrapError;
#[doc(inline)]
pub use derive_more_impl::*;

/// Module containing derive definitions only, without their corresponding traits.
///
/// Use it in your import paths, if you don't want to import traits, but only macros.
pub mod derive {
// This can be unused if no feature is enabled. We already error in that case, but this warning
// distracts from that error. So we suppress the warning.
#[allow(unused_imports)]
#[doc(inline)]
pub use derive_more_impl::*;
}

/// Module containing derive definitions with their corresponding traits along.
///
/// Use it in your import paths, if you do want to import derives along with their traits.
Expand Down

0 comments on commit fd1d3f3

Please sign in to comment.