rust/syn/lit.rs
Source file repositories/reference/linux-study-clean/rust/syn/lit.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/syn/lit.rs- Extension
.rs- Size
- 55843 bytes
- Lines
- 1863
- Domain
- Rust Kernel Layer
- Bucket
- Rust API Membrane
- Inferred role
- Rust Kernel Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
Rust-side wrappers and abstractions around kernel C APIs, ownership contracts, allocation, synchronization, and module integration.
- Rust-side wrappers and abstractions around kernel C APIs, ownership contracts, allocation, synchronization, and module integration.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
struct LitReprstruct LitIntReprstruct LitFloatReprfunction Okfunction spanfunction spanfunction spanfunction spanfunction suffixfunction suffixfunction Somefunction fmtfunction base10_digitsfunction Somefunction fmtfunction parsefunction Somefunction Somefunction Somefunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction bytefunction Somefunction Somefunction suffixfunction next_chrfunction parse_lit_str_rawfunction pubfunction bytefunction parse_lit_byte_str_rawfunction pubfunction bytefunction parse_lit_c_str_rawfunction pubfunction pubfunction Some
Annotated Snippet
struct LitRepr {
token: Literal,
suffix: Box<str>,
}
ast_struct! {
/// An integer literal: `1` or `1u16`.
pub struct LitInt {
repr: Box<LitIntRepr>,
}
}
struct LitIntRepr {
token: Literal,
digits: Box<str>,
suffix: Box<str>,
}
ast_struct! {
/// A floating point literal: `1f64` or `1.0e10f64`.
///
/// Must be finite. May not be infinite or NaN.
pub struct LitFloat {
repr: Box<LitFloatRepr>,
}
}
struct LitFloatRepr {
token: Literal,
digits: Box<str>,
suffix: Box<str>,
}
ast_struct! {
/// A boolean literal: `true` or `false`.
pub struct LitBool {
pub value: bool,
pub span: Span,
}
}
impl LitStr {
pub fn new(value: &str, span: Span) -> Self {
let mut token = Literal::string(value);
token.set_span(span);
LitStr {
repr: Box::new(LitRepr {
token,
suffix: Box::<str>::default(),
}),
}
}
pub fn value(&self) -> String {
let repr = self.repr.token.to_string();
let (value, _suffix) = value::parse_lit_str(&repr);
String::from(value)
}
/// Parse a syntax tree node from the content of this string literal.
///
/// All spans in the syntax tree will point to the span of this `LitStr`.
///
/// # Example
///
/// ```
/// use syn::{Attribute, Error, Expr, Lit, Meta, Path, Result};
///
/// // Parses the path from an attribute that looks like:
/// //
/// // #[path = "a::b::c"]
/// //
/// // or returns `None` if the input is some other attribute.
/// fn get_path(attr: &Attribute) -> Result<Option<Path>> {
/// if !attr.path().is_ident("path") {
/// return Ok(None);
/// }
///
/// if let Meta::NameValue(meta) = &attr.meta {
/// if let Expr::Lit(expr) = &meta.value {
/// if let Lit::Str(lit_str) = &expr.lit {
/// return lit_str.parse().map(Some);
/// }
/// }
/// }
///
/// let message = "expected #[path = \"...\"]";
/// Err(Error::new_spanned(attr, message))
/// }
/// ```
Annotation
- Detected declarations: `struct LitRepr`, `struct LitIntRepr`, `struct LitFloatRepr`, `function Ok`, `function span`, `function span`, `function span`, `function span`, `function suffix`, `function suffix`.
- Atlas domain: Rust Kernel Layer / Rust API Membrane.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.