node: Use `str::trim_end_matches` for stripping '\0' in alias
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
This commit is contained in:
parent
fb63b1c15d
commit
ff81b1a6ed
|
|
@ -121,12 +121,7 @@ impl NodeAnnouncement {
|
|||
|
||||
/// Get the alias as a UTF-8 string.
|
||||
pub fn alias(&self) -> Result<&str, std::str::Utf8Error> {
|
||||
let length = self
|
||||
.alias
|
||||
.iter()
|
||||
.position(|&b| b == 0)
|
||||
.unwrap_or(self.alias.len());
|
||||
str::from_utf8(&self.alias[..length])
|
||||
Ok(str::from_utf8(&self.alias)?.trim_end_matches(0 as char))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue