Skip to content

Add a struct that strips ANSI and implements Display #257

@ChocolateLoverRaj

Description

@ChocolateLoverRaj

console::strip_ansi_codes copies the entire string if it contains any ANSI. In cases where the stripped string needs to be written to something that implements Write, copying the string is completely unnecessary. If there was a struct like WithoutAnsi which implemented Display, it could be used to efficiently write to a serial port (my use case) without copying data.

I can make a PR for this, just let me know how the API should be. Imo it should be something like

pub struct WithoutAnsi;
impl<'a> WithoutAnsi<'a> {
  pub fn new(&'a str) -> Self;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions