mirror of
https://gitee.com/openharmony/third_party_rust_quote
synced 2024-11-23 15:19:40 +00:00
Organize readme a bit
This commit is contained in:
parent
b4f1671357
commit
68ff242bf2
17
README.md
17
README.md
@ -29,15 +29,16 @@ This crate is motivated by the procedural macro use case, but is a
|
||||
general-purpose Rust quasi-quoting library and is not specific to procedural
|
||||
macros.
|
||||
|
||||
*Version requirement: Quote supports rustc 1.31 and up.*
|
||||
|
||||
[*Release notes*](https://github.com/dtolnay/quote/releases)
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
quote = "1.0"
|
||||
```
|
||||
|
||||
*Version requirement: Quote supports rustc 1.31 and up.*<br>
|
||||
[*Release notes*](https://github.com/dtolnay/quote/releases)
|
||||
|
||||
<br>
|
||||
|
||||
## Syntax
|
||||
|
||||
The quote crate provides a [`quote!`] macro within which you can write Rust code
|
||||
@ -76,6 +77,8 @@ let tokens = quote! {
|
||||
};
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Repetition
|
||||
|
||||
Repetition is done using `#(...)*` or `#(...),*` similar to `macro_rules!`. This
|
||||
@ -93,6 +96,8 @@ Note that there is a difference between `#(#var ,)*` and `#(#var),*`—the latte
|
||||
does not produce a trailing comma. This matches the behavior of delimiters in
|
||||
`macro_rules!`.
|
||||
|
||||
<br>
|
||||
|
||||
## Returning tokens to the compiler
|
||||
|
||||
The `quote!` macro evaluates to an expression of type
|
||||
@ -112,6 +117,8 @@ There is a [`From`]-conversion in both directions so returning the output of
|
||||
|
||||
[`From`]: https://doc.rust-lang.org/std/convert/trait.From.html
|
||||
|
||||
<br>
|
||||
|
||||
## Examples
|
||||
|
||||
### Combining quoted fragments
|
||||
@ -206,6 +213,8 @@ quote! {
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Hygiene
|
||||
|
||||
Any interpolated tokens preserve the `Span` information provided by their
|
||||
|
Loading…
Reference in New Issue
Block a user