Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/aienux/blob/main/vendor/quote/src/format.rs
# aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
branch `main` Branches Tags History
`aienux / vendor / quote / src / format.rs`
168 lines · 4816 bytes Raw Blame History
1 /// Formatting macro for constructing `Ident`s.
2 ///
3 ///
4 ///
5 /// # Syntax
6 ///
7 /// Syntax is copied from the [`format!`][alloc::format!] macro, supporting both
8 /// positional and named arguments.
9 ///
10 /// Only a limited set of formatting traits are supported. The current mapping
11 /// of format types to traits is:
12 ///
13 /// * `{}` ⇒ [`IdentFragment`]
14 /// * `{:o}` ⇒ [`Octal`](core::fmt::Octal)
15 /// * `{:x}` ⇒ [`LowerHex`](core::fmt::LowerHex)
16 /// * `{:X}` ⇒ [`UpperHex`](core::fmt::UpperHex)
17 /// * `{:b}` ⇒ [`Binary`](core::fmt::Binary)
18 ///
19 /// See [`core::fmt`] for more information.
20 ///
21 ///
22 ///
23 /// # IdentFragment
24 ///
25 /// Unlike `format!`, this macro uses the [`IdentFragment`] formatting trait by
26 /// default. This trait is like `Display`, with a few differences:
27 ///
28 /// * `IdentFragment` is only implemented for a limited set of types, such as
29 /// unsigned integers and strings.
30 /// * [`Ident`] arguments will have their `r#` prefixes stripped, if present.
31 ///
32 /// [`IdentFragment`]: crate::IdentFragment
33 /// [`Ident`]: proc_macro2::Ident
34 ///
35 ///
36 ///
37 /// # Hygiene
38 ///
39 /// The [`Span`] of the first `Ident` argument is used as the span of the final
40 /// identifier, falling back to [`Span::call_site`] when no identifiers are
41 /// provided.
42 ///
43 /// ```
44 /// # use quote::format_ident;
45 /// # let ident = format_ident!("Ident");
46 /// // If `ident` is an Ident, the span of `my_ident` will be inherited from it.
47 /// let my_ident = format_ident!("My{}{}", ident, "IsCool");
48 /// assert_eq!(my_ident, "MyIdentIsCool");
49 /// ```
50 ///
51 /// Alternatively, the span can be overridden by passing the `span` named
52 /// argument.
53 ///
54 /// ```
55 /// # use quote::format_ident;
56 /// # const IGNORE_TOKENS: &'static str = stringify! {
57 /// let my_span = /* ... */;
58 /// # };
59 /// # let my_span = proc_macro2::Span::call_site();
60 /// format_ident!("MyIdent", span = my_span);
61 /// ```
62 ///
63 /// [`Span`]: proc_macro2::Span
64 /// [`Span::call_site`]: proc_macro2::Span::call_site
65 ///
66 ///