use std::borrow::Cow;
pub(crate) fn normalize_crlf_to_lf(text: &str) -> Cow<'_, str> {
if text.contains('\r') {
let tmp = text.replace("\r\n", "\n");
Cow::Owned(tmp.replace('\r', "\n"))
} else {
Cow::Borrowed(text)
}
}
pub(crate) fn normalize_crlf_to_lf_string(text: String) -> String {
if text.contains('\r') {
let tmp = text.replace("\r\n", "\n");
tmp.replace('\r', "\n")
} else {
text
}
}
pub(crate) fn split_lines_preserve_trailing(text: &str) -> Vec<String> {
text.split('\n').map(|line| line.to_string()).collect()
}