From cf56527c193ff8eb9d5e3fa772167969f7bb6d1a Mon Sep 17 00:00:00 2001 From: Hocuri Date: Mon, 27 Apr 2026 11:19:49 +0200 Subject: [PATCH 1/3] docs: Discourage `into()`, `try_into()` and `parse()` --- STYLE.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/STYLE.md b/STYLE.md index 7d97e73342..0c4c17f98f 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, use `Type::from()`, `Type::try_from()` or `Type::from_str()` directly +rather than `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. From 44ee92f9713445a9cfde656d28e04498c9474bf2 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Mon, 27 Apr 2026 13:17:24 +0200 Subject: [PATCH 2/3] Note JsonRPC API --- STYLE.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/STYLE.md b/STYLE.md index 0c4c17f98f..2f814ae58c 100644 --- a/STYLE.md +++ b/STYLE.md @@ -167,10 +167,14 @@ Follow Rust guidelines for the documentation comments: For internal types, implementing `From`, `TryFrom` or `FromStr` is discouraged. Instead, a `new()` function is recommended. -For external types, use `Type::from()`, `Type::try_from()` or `Type::from_str()` directly -rather than `into()`, `try_into()` or `parse()`. +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. + +A notable exception is the Json-RPC API bindings, +where the API types have `From` implementatons to and from the core types. +Here, it is assumed to be clear enough which code is called. From e254aeb48aecd3666edcd6adf3d4598793f1998b Mon Sep 17 00:00:00 2001 From: Hocuri Date: Tue, 28 Apr 2026 15:47:56 +0200 Subject: [PATCH 3/3] Drop last paragraph --- STYLE.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/STYLE.md b/STYLE.md index 2f814ae58c..98ff96e366 100644 --- a/STYLE.md +++ b/STYLE.md @@ -174,7 +174,3 @@ 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. - -A notable exception is the Json-RPC API bindings, -where the API types have `From` implementatons to and from the core types. -Here, it is assumed to be clear enough which code is called.