Skip to content

Commit

Permalink
Std: Char collector for String
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Mar 27, 2024
1 parent 645e3f0 commit 4bc2691
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/scope/trait.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('trait', () => {
['std::io::trace::Trace'],
['std::eq::Eq'],
['std::iter::Collector<std::string::String>'],
['std::iter::Collector<std::char::Char>'],
['std::copy::Copy']
])

Expand Down
9 changes: 9 additions & 0 deletions src/std/string.no
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::iter::MapAdapter

pub type String

impl String {
Expand Down Expand Up @@ -35,6 +37,13 @@ impl Collector<String> for String {
}
}

impl Collector<Char> for String {
fn fromIter(iter: Iter<Char>): Self {
// TODO: method ref
iter.map(|c| { c.show() }).collect<String>()
}
}

impl Copy for String {
fn copy(self): Self {
copy(self)
Expand Down

0 comments on commit 4bc2691

Please sign in to comment.