pub fn unix2dos<T: AsRef<str> + ?Sized>(input: &T) -> Cow<'_, str>
Expand description

Converts UNIX-style line endings (\n) to DOS-style (\r\n).

The input string may already be in correct format, so this function returns Cow<str>, to avoid unnecessary allocation and copying.

Examples

assert_eq!(newline_converter::unix2dos("\nfoo\nbar\n"), "\r\nfoo\r\nbar\r\n");

Already present DOS line breaks are respected:

assert_eq!(newline_converter::unix2dos("\nfoo\r\nbar\n"), "\r\nfoo\r\nbar\r\n");