Merge pull request #1158 from frank2/rangelimits-to-tokens

#1157 implement ToTokens for RangeLimits enum
This commit is contained in:
David Tolnay 2022-04-05 15:45:11 -07:00 committed by GitHub
commit d94e7f191b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
}
}