rust-lang / rust-lang/rfcs

Have std::string::ToString for X automatically provide std::convert::From<X> for String

Open
#2,209 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

breaking-change T-libs
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

Is there a good reason the following can't be done?

impl<T> std::convert::From<T> for std::string::String where T: std::string::ToString {
    fn from(t: T) -> Self {
        t.to_string()
    }

The only thing I can think of is if the value of T converted to String has a different meaning of the value of T.display() (as that's where a lot of the ToString implementations are coming from) such that you might want different behavior there.

Being able to do something like s: String = 42.into() anywhere would be nice.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by evaluating the proposed blanket From implementation and its API implications; done means reaching a documented decision on whether this conversion should be added.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.