docs: Discourage into(), try_into() and parse() (#8180)

Follow-up to
https://github.com/chatmail/core/pull/8178#issuecomment-4322738959

In a previous version, I added a note that the JsonRPC API is a notable exception, but I removed it.
This commit is contained in:
Hocuri
2026-04-30 13:58:19 +02:00
committed by GitHub
parent 585de7d18b
commit 4b528e426b

View File

@@ -161,3 +161,16 @@ are documented.
Follow Rust guidelines for the documentation comments:
<https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#summary-sentence>
## Do not use `into()`, `try_into()` or `parse()`
For internal types, implementing `From`, `TryFrom` or `FromStr` is discouraged.
Instead, a `new()` function is recommended.
For external types, prefer using `Type::from()`, `Type::try_from()` or `Type::from_str()`
over `into()`, `try_into()` or `parse()`.
Calling `into()`, `try_into()` or `parse()`
creates an indirection,
which is hard to follow for people who are not familiar with Rust,
or who are not using rust-analyzer.