Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/time-macros/src/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  to_tokens.rs

  Sprache: Rust
 

use std::num::NonZeroU16;

use proc_macro::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};

/// Turn a type into a [`TokenStream`].
pub(cratetrait ToTokenStream: Sized {
    fn append_to(self, ts: &mut TokenStream);
}

pub(cratetrait ToTokenTree: Sized {
    fn into_token_tree(self) -> TokenTree;
}

impl<T: ToTokenTree> ToTokenStream for T {
    fn append_to(self, ts: &mut TokenStream) {
        ts.extend([self.into_token_tree()])
    }
}

impl ToTokenTree for bool {
    fn into_token_tree(self) -> TokenTree {
        let lit = if self { "true" } else { "false" };
        TokenTree::Ident(Ident::new(lit, Span::mixed_site()))
    }
}

impl ToTokenStream for TokenStream {
    fn append_to(self, ts: &mut TokenStream) {
        ts.extend(self)
    }
}

impl ToTokenTree for TokenTree {
    fn into_token_tree(self) -> TokenTree {
        self
    }
}

impl ToTokenTree for &str {
    fn into_token_tree(self) -> TokenTree {
        TokenTree::Literal(Literal::string(self))
    }
}

impl ToTokenTree for NonZeroU16 {
    fn into_token_tree(self) -> TokenTree {
        quote_group! {{
            unsafe { ::core::num::NonZeroU16::new_unchecked(#(self.get())) }
        }}
    }
}

macro_rules! impl_for_tree_types {
    ($($type:ty)*) => {$(
        impl ToTokenTree for $type {
            fn into_token_tree(self) -> TokenTree {
                TokenTree::from(self)
            }
        }
    )*};
}
impl_for_tree_types![Ident Literal Group Punct];

macro_rules! impl_for_int {
    ($($type:ty => $method:ident)*) => {$(
        impl ToTokenTree for $type {
            fn into_token_tree(self) -> TokenTree {
                TokenTree::from(Literal::$method(self))
            }
        }
    )*};
}
impl_for_int! {
    i8 => i8_unsuffixed
    u8 => u8_unsuffixed
    u16 => u16_unsuffixed
    i32 => i32_unsuffixed
    u32 => u32_unsuffixed
}

Messung V0.5 in Prozent
C=84 H=93 G=88

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-18) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.