Implement the new fields for statistics cookie.

This commit is contained in:
Tom Alexander 2023-12-11 12:51:07 -05:00
parent ab281de3c6
commit 4af0d3141f
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 11 additions and 4 deletions

View File

@ -40,7 +40,7 @@ fn percent_statistics_cookie<'b, 'g, 'r, 's>(
tag("%]"),
)))(input)?;
let value = get_consumed(input, remaining);
let (remaining, _trailing_whitespace) =
let (remaining, post_blank) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining);
Ok((
@ -48,6 +48,7 @@ fn percent_statistics_cookie<'b, 'g, 'r, 's>(
StatisticsCookie {
source: source.into(),
value: value.into(),
post_blank: post_blank.map(Into::<&str>::into),
},
))
}
@ -68,7 +69,7 @@ fn fraction_statistics_cookie<'b, 'g, 'r, 's>(
tag("]"),
)))(input)?;
let value = get_consumed(input, remaining);
let (remaining, _trailing_whitespace) =
let (remaining, post_blank) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining);
Ok((
@ -76,6 +77,7 @@ fn fraction_statistics_cookie<'b, 'g, 'r, 's>(
StatisticsCookie {
source: source.into(),
value: value.into(),
post_blank: post_blank.map(Into::<&str>::into),
},
))
}

View File

@ -263,6 +263,7 @@ pub struct Target<'s> {
pub struct StatisticsCookie<'s> {
pub source: &'s str,
pub value: &'s str,
pub post_blank: Option<&'s str>,
}
#[derive(Debug)]
@ -894,11 +895,15 @@ impl<'s> StandardProperties<'s> for StatisticsCookie<'s> {
}
fn get_contents<'b>(&'b self) -> Option<&'s str> {
todo!()
None
}
fn get_post_blank(&self) -> PostBlank {
todo!()
self.post_blank
.map(|post_blank| post_blank.chars().count())
.unwrap_or(0)
.try_into()
.expect("Too much post-blank to fit into a PostBlank.")
}
}