Skip to content

Commit 478a90e

Browse files
committed
wip
1 parent dc8ec6c commit 478a90e

File tree

135 files changed

+1377
-3550318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+1377
-3550318
lines changed

rust/mlt-nom/src/v01/id.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::fmt::Debug;
2+
use std::fmt::Formatter;
3+
14
use borrowme::borrowme;
25

36
use crate::MltError;
@@ -31,11 +34,37 @@ pub enum RawIdValue<'a> {
3134
}
3235

3336
/// Decoded ID values as a vector of optional 64-bit unsigned integers
34-
#[derive(Debug, Clone, Default, PartialEq)]
37+
#[derive(Clone, Default, PartialEq)]
3538
pub struct DecodedId(Option<Vec<Option<u64>>>);
3639

3740
impl_decodable!(Id<'a>, RawId<'a>, DecodedId);
3841

42+
impl Debug for DecodedId {
43+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
44+
match &self.0 {
45+
None => write!(f, "DecodedId(None)"),
46+
Some(ids) => {
47+
let preview: Vec<String> = ids
48+
.iter()
49+
.take(8)
50+
.map(|opt_id| {
51+
opt_id
52+
.map(|id| id.to_string())
53+
.unwrap_or_else(|| "None".to_string())
54+
})
55+
.collect();
56+
write!(
57+
f,
58+
"DecodedId([{}{}; {}])",
59+
preview.join(","),
60+
if ids.len() > 8 { ", ..." } else { "" },
61+
ids.len()
62+
)
63+
}
64+
}
65+
}
66+
}
67+
3968
impl<'a> From<RawId<'a>> for Id<'a> {
4069
fn from(value: RawId<'a>) -> Self {
4170
Self::Raw(value)

0 commit comments

Comments
 (0)