Skip to content

Commit

Permalink
Merge pull request #1597 from dtolnay/copyprintnothing
Browse files Browse the repository at this point in the history
Implement Copy and ToTokens for Nothing
  • Loading branch information
dtolnay authored Mar 16, 2024
2 parents 36a4122 + 4f6c052 commit fd1f2aa
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ use crate::lookahead;
use crate::punctuated::Punctuated;
use crate::token::Token;
use proc_macro2::{Delimiter, Group, Literal, Punct, Span, TokenStream, TokenTree};
#[cfg(feature = "printing")]
use quote::ToTokens;
use std::cell::Cell;
use std::fmt::{self, Debug, Display};
#[cfg(feature = "extra-traits")]
Expand Down Expand Up @@ -1354,6 +1356,26 @@ impl Parse for Nothing {
}
}

#[cfg(feature = "printing")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for Nothing {
fn to_tokens(&self, tokens: &mut TokenStream) {
let _ = tokens;
}
}

#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for Nothing {
fn clone(&self) -> Self {
*self
}
}

#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Copy for Nothing {}

#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for Nothing {
Expand Down

0 comments on commit fd1f2aa

Please sign in to comment.