From 4b528e426b853a9b3c4c3741006d3cb9c96c3074 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Thu, 30 Apr 2026 13:58:19 +0200 Subject: [PATCH] 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. --- STYLE.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/STYLE.md b/STYLE.md index 7d97e7334..98ff96e36 100644 --- a/STYLE.md +++ b/STYLE.md @@ -161,3 +161,16 @@ are documented. Follow Rust guidelines for the documentation comments: + +## 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.