mirror of
https://gitee.com/openharmony/third_party_rust_quote
synced 2024-11-27 01:11:38 +00:00
Add a version of into_token_stream that takes &self
This commit is contained in:
parent
682eea40f3
commit
c480dc7dfb
@ -54,6 +54,16 @@ pub trait ToTokens {
|
||||
/// ```
|
||||
fn to_tokens(&self, tokens: &mut TokenStream);
|
||||
|
||||
/// Convert `self` directly into a `TokenStream` object.
|
||||
///
|
||||
/// This method is implicitly implemented using `to_tokens`, and acts as a
|
||||
/// convenience method for consumers of the `ToTokens` trait.
|
||||
fn to_token_stream(&self) -> TokenStream {
|
||||
let mut tokens = TokenStream::new();
|
||||
self.to_tokens(&mut tokens);
|
||||
tokens
|
||||
}
|
||||
|
||||
/// Convert `self` directly into a `TokenStream` object.
|
||||
///
|
||||
/// This method is implicitly implemented using `to_tokens`, and acts as a
|
||||
@ -62,9 +72,7 @@ pub trait ToTokens {
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let mut tokens = TokenStream::new();
|
||||
self.to_tokens(&mut tokens);
|
||||
tokens
|
||||
self.to_token_stream()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user