]> git.proxmox.com Git - proxmox-backup.git/blobdiff - pbs-tools/src/str.rs
move client to pbs-client subcrate
[proxmox-backup.git] / pbs-tools / src / str.rs
index 9b2d66ef01bdb54f2fd26ebe06204941f47825d7..387fe5fe18e34f17db6102c74536ed246c6ba08d 100644 (file)
@@ -15,3 +15,13 @@ pub fn join<S: Borrow<str>>(data: &[S], sep: char) -> String {
     list
 }
 
+pub fn strip_ascii_whitespace(line: &[u8]) -> &[u8] {
+    let line = match line.iter().position(|&b| !b.is_ascii_whitespace()) {
+        Some(n) => &line[n..],
+        None => return &[],
+    };
+    match line.iter().rev().position(|&b| !b.is_ascii_whitespace()) {
+        Some(n) => &line[..(line.len() - n)],
+        None => &[],
+    }
+}