lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

wire.rs (591B)


      1 #[cfg(not(feature = "std"))]
      2 use alloc::{
      3     string::{String, ToString},
      4     vec::Vec,
      5 };
      6 
      7 pub fn canonicalize_tags(tags: &mut Vec<Vec<String>>) {
      8     tags.retain(|t| t.first().map(|s| !s.trim().is_empty()).unwrap_or(false));
      9     for t in tags.iter_mut() {
     10         for s in t.iter_mut() {
     11             let trimmed = s.trim();
     12             if trimmed.len() != s.len() {
     13                 *s = trimmed.to_string();
     14             }
     15         }
     16     }
     17     tags.sort_by(|a, b| a.first().cmp(&b.first()).then_with(|| a.cmp(b)));
     18     tags.dedup();
     19 }
     20 
     21 pub fn empty_content() -> String {
     22     String::new()
     23 }