1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Copyright 2020 Andreas Kurth
//
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//! Various utilities
// CC BY-SA 4.0 Sven Marnach
// Adapted from https://stackoverflow.com/a/55041833.
pub fn trim_newline(mut s: String) -> String {
if s.ends_with('\n') {
s.pop();
if s.ends_with('\r') {
s.pop();
}
}
s
}
