headers-core 0.0.1

typed HTTP headers
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Encoding utilities.

use std::fmt;

/// Format an array into a comma-delimited string.
pub fn comma_delimited<T: fmt::Display>(f: &mut fmt::Formatter, mut iter: impl Iterator<Item=T>) -> fmt::Result {
    if let Some(part) = iter.next() {
        fmt::Display::fmt(&part, f)?;
    }
    for part in iter {
        f.write_str(", ")?;
        fmt::Display::fmt(&part, f)?;
    }
    Ok(())
}