Skip to content

Commit

Permalink
dtolnay#1157 implement ToTokens for RangeLimits enum
Browse files Browse the repository at this point in the history
  • Loading branch information
frank2 committed Apr 5, 2022
1 parent 86c9fa4 commit 72e6ffc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3346,14 +3346,22 @@ pub(crate) mod printing {

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ExprRange {
impl ToTokens for RangeLimits {
fn to_tokens(&self, tokens: &mut TokenStream) {
outer_attrs_to_tokens(&self.attrs, tokens);
self.from.to_tokens(tokens);
match &self.limits {
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);
self.limits.to_tokens(tokens);
self.to.to_tokens(tokens);
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 72e6ffc

Please sign in to comment.