mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 05:50:31 +08:00
node: Use str::trim_end_matches for stripping '\0' in alias
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user