Crate join_string

source ·
Expand description

A simple crate to join the elements of iterators, interspersing a separator between all elements.

This is done somewhat efficiently, if possible, meaning if the iterator is cheaply clonable you can directly print the result of Join::join() without creating a temporary String in memory.

use join_string::Join;
 
assert_eq!(
    "foo bar baz".split_whitespace().join(", ").into_string(),
    "foo, bar, baz");
 
println!("{}",
    "foo bar baz".split_whitespace()
        .map(|s| s.chars().rev().join(""))
        .join(' '));
// Output: oof rab zab

Structs

Traits

  • Trait that provides a method to join elements of an iterator, interspersing a separator between all elements.

Functions