only require Show for elements joined with connect
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
Issue by panzi
Saturday May 03, 2014 at 02:19 GMT
For earlier discussion, see https://github.com/rust-lang/rust/issues/13911
This issue was labelled with: in the Rust repository
In most high level languages it's easy to turn a list/array of things into a comma separated string. In Rust there is the connect method, but it requires the elements to implement the trait std::str::Str. I would like this method to require std::fmt::Show instead. Alternatively a join method with according semantics that requires std::fmt::Show would suffice.
Currently you have to write:
let xs = [1, 2, 3];
let str_xs: ~[~str] = xs.iter().map(|x| x.to_str()).collect();
println!("xs = {}", str_xs.connect(", "));
let mut ys = Vec::new();
ys.push(4);
ys.push(5);
ys.push(6);
let str_ys: Vec<~str> = ys.iter().map(|y| y.to_str()).collect();
println!("ys = {}", str_ys.connect(", "));
This is pretty horrible. This would be much nicer:
let xs = [1, 2, 3];
println!("xs = {}", xs.connect(", "));
let mut ys = Vec::new();
ys.push(4);
ys.push(5);
ys.push(6);
println!("ys = {}", ys.connect(", "));
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the earlier discussion in rust-lang/rust#13911 and the surrounding RFC context. Investigate the existing connect API and the Str and Show traits in the Rust repository; done means the preferred API change is clearly specified and accepted for implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100