]> git.proxmox.com Git - proxmox-backup.git/commitdiff
don't enforce Vec and String in tools::join
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 30 Nov 2020 12:56:58 +0000 (13:56 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 30 Nov 2020 12:56:59 +0000 (13:56 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/tools.rs

index 23fd99d77bc2ad003a9e690d63f7f9ab9cedbc09..f3c50ad9c5711e1d4e996e0b6c9c6d47a3da861a 100644 (file)
@@ -2,6 +2,7 @@
 //!
 //! This is a collection of small and useful tools.
 use std::any::Any;
+use std::borrow::Borrow;
 use std::collections::HashMap;
 use std::hash::BuildHasher;
 use std::fs::File;
@@ -297,14 +298,14 @@ pub fn percent_encode_component(comp: &str) -> String {
     utf8_percent_encode(comp, percent_encoding::NON_ALPHANUMERIC).to_string()
 }
 
-pub fn join(data: &Vec<String>, sep: char) -> String {
+pub fn join<S: Borrow<str>>(data: &[S], sep: char) -> String {
     let mut list = String::new();
 
     for item in data {
         if !list.is_empty() {
             list.push(sep);
         }
-        list.push_str(item);
+        list.push_str(item.borrow());
     }
 
     list