#1157 implement ToTokens for RangeLimits enum

This commit is contained in:
frank2 2022-04-05 15:27:40 -07:00
parent 86c9fa49f5
commit 72e6ffc681
2 changed files with 13 additions and 8 deletions

View File

@ -3344,16 +3344,24 @@ pub(crate) mod printing {
}
}
#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for RangeLimits {
fn to_tokens(&self, tokens: &mut TokenStream) {
match self {
RangeLimits::HalfOpen(t) => t.to_tokens(tokens),
RangeLimits::Closed(t) => t.to_tokens(tokens),
}
}
}
#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ExprRange {
fn to_tokens(&self, tokens: &mut TokenStream) {
outer_attrs_to_tokens(&self.attrs, tokens);
self.from.to_tokens(tokens);
match &self.limits {
RangeLimits::HalfOpen(t) => t.to_tokens(tokens),
RangeLimits::Closed(t) => t.to_tokens(tokens),
}
self.limits.to_tokens(tokens);
self.to.to_tokens(tokens);
}
}

View File

@ -878,10 +878,7 @@ mod printing {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
self.lo.to_tokens(tokens);
match &self.limits {
RangeLimits::HalfOpen(t) => t.to_tokens(tokens),
RangeLimits::Closed(t) => t.to_tokens(tokens),
}
self.limits.to_tokens(tokens);
self.hi.to_tokens(tokens);
}
}