I think there is no ambiguity in from_str as a method name so "choose a
less ambiguous method name" is unnecessary, and it can't be a FromStr
impl in this case because FromStr's error type cannot borrow from the
input string slice.
warning: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str`
--> serde_derive_internals/src/case.rs:50:5
|
50 | / pub fn from_str(rename_all_str: &str) -> Result<Self, ParseError> {
51 | | for (name, rule) in RENAME_RULES {
52 | | if rename_all_str == *name {
53 | | return Ok(*rule);
... |
58 | | })
59 | | }
| |_____^
|
= note: `#[warn(clippy::should_implement_trait)]` on by default
= help: consider implementing the trait `std::str::FromStr` or choosing a less ambiguous method name
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
This usage is fine. It's mirroring trait signatures in syn::visit::Visit.
error: unused `self` argument
--> serde_derive/src/bound.rs:241:24
|
241 | fn visit_macro(&mut self, _mac: &'ast syn::Macro) {}
| ^^^^^^^^^
|
note: the lint level is defined here
--> serde_derive/src/lib.rs:18:22
|
18 | #![deny(clippy::all, clippy::pedantic)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::unused_self)]` implied by `#[deny(clippy::pedantic)]`
= help: consider refactoring to a associated function
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_self
The builtin visitor is fairly expensive to compile (3700 lines of code),
particularly if something else in the dependency graph also enables
syn/full. For the usage in serde_derive, it turns out to be easy to
replace.
The implied lifetime bound on T only works on 1.31+. Older versions fail
with:
error[E0309]: the parameter type `T` may not live long enough
--> serde/src/private/de.rs:2548:37
|
2548 | pub struct Borrowed<'de, T: ?Sized>(pub &'de T);
| -- ^^^^^^^^^^
| |
| help: consider adding an explicit lifetime bound `T: 'de`...
|
note: ...so that the reference type `&'de T` does not outlive the data it points at
--> serde/src/private/de.rs:2548:37
|
2548 | pub struct Borrowed<'de, T: ?Sized>(pub &'de T);
| ^^^^^^^^^^
The BorrowedDeserializer was added in #1917, but only makes sense for
&str and &[u8], not for u64 which also needs to be have an
IdentifierDeserializer impl.
We shouldn't try to use the same macro for public and private types. The
API for a private type can usually be pared much further down to save
compile time, such as Debug and Copy and Clone impls.
All of these macros are only used internally within the serde crate.
There is no need for them to have #[macro_export] and need to be hidden
from docs.