minidom: Make the whole crate almost no_std

Only std::io is still missing, maybe we should consider using a crate
implementing its API on top of no_std?
This commit is contained in:
Emmanuel Gil Peyrot 2025-02-25 01:06:30 +01:00 committed by Link Mauve
commit d203a348cb
7 changed files with 33 additions and 27 deletions

View file

@ -7,8 +7,9 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use alloc::collections::BTreeMap;
use alloc::string::String;
use core::fmt;
use std::collections::BTreeMap;
pub type Prefix = Option<String>;
pub type Namespace = String;
@ -23,15 +24,11 @@ impl fmt::Debug for Prefixes {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Prefixes(")?;
for (prefix, namespace) in &self.prefixes {
write!(
f,
"xmlns{}={:?} ",
match prefix {
None => String::new(),
Some(prefix) => format!(":{}", prefix),
},
namespace
)?;
if let Some(prefix) = prefix {
write!(f, "xmlns:{prefix}={namespace:?} ")?;
} else {
write!(f, "xmlns={namespace:?} ")?;
}
}
write!(f, ")")
}