jam1garner / owo-colors

A zero-allocation no_std-compatible zero-cost way to add color to your Rust terminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implementation of `std::slice::Join` for `owo_colors::Styled`

tecc opened this issue · comments

commented

It's just a nice thing to have - instead of writing

strings
    .iter()
    .map(|string| string.style(some_style).to_string())
    .collect::<Vec<_>>()
    .join(", ")

It could instead be the following

strings
    .iter()
    .map(|string| string.style(some_style))
    .collect::<Vec<_>>()
    .join(", ")

Sure, it's a tiny thing, but it does make such code look less clean to me with the former option.

Pretty sure this just flat out isn't possible--correct me if I'm wrong but the implementation of Join requires returning a borrowed slice. owo-colors doesn't have any pre-rendered buffer of the colored text, the coloration and text are separately stored even for Styled, so there's no existing slice to borrow.

Feel free to reopen if I'm wrong