Quantcast
Channel: How do I remove line feeds / line breaks from std::string::String? - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Shepmaster for How do I remove line feeds / line breaks from...

First, you have to define what a "line feed" is. I choose the character \n. In that case, I'd just use replace: println!("{}", string.replace('\n', "")) This works for for &str and String. If you...

View Article



How do I remove line feeds / line breaks from std::string::String?

I cannot find something that will do this. What I have so far is only for whitespace: pub fn minify(&self) { println!("Minify task started ... "); let mut string_iter =...

View Article

Answer by Juan Campa for How do I remove line feeds / line breaks from...

You can now do this in-place with either of these two options:string.retain(|c| c != '\n')or (nightly only)string.remove_matches('\n');Check out this playground to see it working

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images