<commit_before>//! Collection Utility

/// Clone a vector consisting of item references to 
/// a new vector owning cloned items.
#[inline]
pub fn to_owned_vec<T: Clone>(r: &Vec<&T>) -> Vec<T> {
  r.iter().map(|v| (*v).clone()).collect::<Vec<T>>()
}

#[test]
pub fn test() {
  let x = 3; let y = 4;
  
  let ref_vec : Vec<&usize> = vec![&x, &y];  
  let expected: Vec<usize> = vec![x, y];  
  assert_eq!(to_owned_vec(&ref_vec), expected);
}<commit_msg>Add to_boxed_vec util function.<commit_after>//! Collection Utility

/// Clone a vector consisting of item references to 
/// a new vector owning cloned items.
#[inline]
pub fn to_owned_vec<T: Clone>(v: &Vec<&T>) -> Vec<T> 
{
  v.iter().map(|e| (*e).clone()).collect::<Vec<T>>()
}

/// Convert Vec<T> into Vec<Box<T>>
///
/// It is usually used for arguments of nested Struct or Enum.
pub fn to_boxed_vec<T>(v: Vec<T>) -> Vec<Box<T>>
{
  v.into_iter().map(|e| Box::new(e)).collect::<Vec<Box<T>>>()
}

#[inline]

#[test]
pub fn test() {
  let x = 3; let y = 4;
  
  let ref_vec : Vec<&usize> = vec![&x, &y];  
  let expected: Vec<usize> = vec![x, y];  
  assert_eq!(to_owned_vec(&ref_vec), expected);
}
{'fraction_non_alphanumeric': 0.21509106678230702, 'fraction_numerical': 0.003469210754553339, 'mean_word_length': 3.8284518828451883, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2440905', 'n_tokens_mistral': 465, 'n_tokens_neox': 459, 'n_words': 122}