geckolib: fix geckolib build by implementing display on Atoms.

This commit is contained in:
Emilio Cobos Álvarez 2016-06-27 23:20:52 +00:00
parent 2d566ef0ef
commit e015e87697
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 15 additions and 3 deletions

View file

@ -15,6 +15,7 @@ use gecko_bindings::structs::nsIAtom;
use heapsize::HeapSizeOf;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::borrow::Cow;
use std::char;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
@ -206,6 +207,15 @@ impl fmt::Debug for Atom {
}
}
impl fmt::Display for Atom {
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
for c in char::decode_utf16(self.as_slice().iter().cloned()) {
try!(write!(w, "{}", c.unwrap_or(char::REPLACEMENT_CHARACTER)))
}
Ok(())
}
}
impl<'a> From<&'a str> for Atom {
#[inline]
fn from(string: &str) -> Atom {