mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
implement Display trait for InfoHash #226
This commit is contained in:
parent
34b45e923f
commit
e6b37c1c5f
1 changed files with 13 additions and 0 deletions
|
|
@ -275,6 +275,19 @@ pub fn invalid_data() -> ::std::io::Error {
|
|||
::std::io::Error::new(::std::io::ErrorKind::InvalidData, "invalid data")
|
||||
}
|
||||
|
||||
impl std::fmt::Display for InfoHash {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
self.0
|
||||
.iter()
|
||||
.map(|b| format!("{:02x}", b))
|
||||
.collect::<String>()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for InfoHash {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue