rust/syn/punctuated.rs
Source file repositories/reference/linux-study-clean/rust/syn/punctuated.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/syn/punctuated.rs- Extension
.rs- Size
- 31306 bytes
- Lines
- 1158
- 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
function newfunction Somefunction push_punctfunction popfunction Somefunction clearfunction Okfunction nextfunction nextfunction nextfunction nextfunction nextfunction nextfunction punct_mutfunction to_tokensfunction to_tokens
Annotated Snippet
if let Some((value, _punct)) = self.inner.get(index) {
Some(value)
} else if index == self.inner.len() {
self.last.as_deref()
} else {
None
}
}
/// Mutably borrows the element at the given index.
pub fn get_mut(&mut self, index: usize) -> Option<&mut T> {
let inner_len = self.inner.len();
if let Some((value, _punct)) = self.inner.get_mut(index) {
Some(value)
} else if index == inner_len {
self.last.as_deref_mut()
} else {
None
}
}
/// Returns an iterator over borrowed syntax tree nodes of type `&T`.
pub fn iter(&self) -> Iter<T> {
Iter {
inner: Box::new(NoDrop::new(PrivateIter {
inner: self.inner.iter(),
last: self.last.as_ref().map(Box::as_ref).into_iter(),
})),
}
}
/// Returns an iterator over mutably borrowed syntax tree nodes of type
/// `&mut T`.
pub fn iter_mut(&mut self) -> IterMut<T> {
IterMut {
inner: Box::new(NoDrop::new(PrivateIterMut {
inner: self.inner.iter_mut(),
last: self.last.as_mut().map(Box::as_mut).into_iter(),
})),
}
}
/// Returns an iterator over the contents of this sequence as borrowed
/// punctuated pairs.
pub fn pairs(&self) -> Pairs<T, P> {
Pairs {
inner: self.inner.iter(),
last: self.last.as_ref().map(Box::as_ref).into_iter(),
}
}
/// Returns an iterator over the contents of this sequence as mutably
/// borrowed punctuated pairs.
pub fn pairs_mut(&mut self) -> PairsMut<T, P> {
PairsMut {
inner: self.inner.iter_mut(),
last: self.last.as_mut().map(Box::as_mut).into_iter(),
}
}
/// Returns an iterator over the contents of this sequence as owned
/// punctuated pairs.
pub fn into_pairs(self) -> IntoPairs<T, P> {
IntoPairs {
inner: self.inner.into_iter(),
last: self.last.map(|t| *t).into_iter(),
}
}
/// Appends a syntax tree node onto the end of this punctuated sequence. The
/// sequence must already have a trailing punctuation, or be empty.
///
/// Use [`push`] instead if the punctuated sequence may or may not already
/// have trailing punctuation.
///
/// [`push`]: Punctuated::push
///
/// # Panics
///
/// Panics if the sequence is nonempty and does not already have a trailing
/// punctuation.
pub fn push_value(&mut self, value: T) {
assert!(
self.empty_or_trailing(),
"Punctuated::push_value: cannot push value if Punctuated is missing trailing punctuation",
);
self.last = Some(Box::new(value));
}
Annotation
- Detected declarations: `function new`, `function Some`, `function push_punct`, `function pop`, `function Some`, `function clear`, `function Ok`, `function next`, `function next`, `function next`.
- 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.