id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/src/util/linked_list.rs:11 | let tail_ptr = unsafe {
L::pointers(self.guard).as_ref().get_prev().unwrap()
};
// Compare the tail pointer with the address of the guard node itself.
// If the guard points at itself, then there are no other nodes and
// the list is considered empty.
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:12 | prev: None,
next: None,
_pin: PhantomPinned,
}),
}
}
pub(crate) fn get_prev(&self) -> Option<NonNull<T>> {
// SAFETY: prev is the first field in PointersInner, which is #[repr(C)].
unsafe {
let inner = self.inner.get();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:13 | }
}
}
impl<T> fmt::Debug for Pointers<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let prev = self.get_prev();
let next = self.get_next();
f.debug_struct("Pointers")
.field("prev", &prev)
.field("next", &next)
.finish()
}
}
#[c... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:14 | unsafe fn pointers(target: NonNull<Entry>) -> NonNull<Pointers<Entry>> {
target.cast()
}
}
fn entry(val: i32) -> Pin<Box<Entry>> {
Box::pin(Entry {
pointers: Pointers::new(),
val,
})
}
fn ptr(r: &Pin<Box<Entry>>) -> NonNull<Entry> {
r... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:15 | assert!($e.pointers.get_prev().is_none());
}};
}
#[cfg(test)]
macro_rules! assert_ptr_eq {
($a:expr, $b:expr) => {{
// Deal with mapping a Pin<&mut T> -> Option<NonNull<T>>
assert_eq!(Some($a.as_ref().get_ref().into()), $b)
}};
}
#[test]
fn const... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | let b = entry(7);
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
list.push_front(a.as_ref());
let entry = list.pop_back().unwrap();
assert_eq!(5, entry.val);
assert!(list.is_empty());
list.push_front(b.as_ref());
let entry = list.pop_ba... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:17 | assert!(!list.is_empty());
assert!(list.remove(ptr(&c)).is_some());
assert_clean!(c);
// `b` should be no longer there and can't be removed twice
assert!(list.remove(ptr(&c)).is_none());
assert!(list.is_empty());
}
unsafe {
// Rem... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:18 | }
unsafe {
// Remove last
// Remove middle
let mut list = LinkedList::new();
push_all(&mut list, &[c.as_ref(), b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&c)).is_some());
assert_clean!(c);
assert!(b.pointers.get_next(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:19 | }
unsafe {
// Remove last of two
let mut list = LinkedList::new();
push_all(&mut list, &[b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&b)).is_some());
assert_clean!(b);
assert_ptr_eq!(a, list.head);
assert_ptr_eq!(a, l... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:20 | list.push_front(b.as_ref());
list.push_front(a.as_ref());
assert!(list.remove(ptr(&c)).is_none());
}
}
#[test]
fn count() {
let mut list = CountedLinkedList::<&Entry, <&Entry as Link>::Target>::new();
assert_eq!(0, list.count());
let a = entry(5);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1d785fd66fce4a9125c6f0c403dfe1921d011539 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/src/util/linked_list.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:6 | if let Some(next) = L::pointers(node).as_ref().get_next() {
debug_assert_eq!(L::pointers(next).as_ref().get_prev(), Some(node));
L::pointers(next)
.as_mut()
.set_prev(L::pointers(node).as_ref().get_prev());
} else {
// This might be the last it... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:7 | unsafe { Some(&*tail.as_ptr()) }
}
}
impl<L: Link> Default for LinkedList<L, L::Target> {
fn default() -> Self {
Self::new()
}
}
// ===== impl DrainFilter =====
cfg_io_readiness! {
pub(crate) struct DrainFilter<'a, T: Link, F> {
list: &'a mut LinkedList<T, T::Target>,
filter: ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:8 | fn next(&mut self) -> Option<Self::Item> {
while let Some(curr) = self.curr {
// safety: the pointer references data contained by the list
self.curr = unsafe { T::pointers(curr).as_ref() }.get_next();
// safety: the value is still owned by the linked list.
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:9 | impl<U, L: Link<Handle = NonNull<U>>> LinkedList<L, L::Target> {
/// Turns a linked list into the guarded version by linking the guard node
/// with the head and tail nodes. Like with other nodes, you should guarantee
/// that the guard node is pinned in memory.
pub(crate) fn into_guarde... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:10 | if tail_ptr != self.guard {
Some(tail_ptr)
} else {
None
}
}
/// Removes the last element from a list and returns it, or None if it is
/// empty.
pub(crate) fn pop_back(&mut self) -> Option<L::Handle> {
unsafe {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:11 | pub(crate) fn get_prev(&self) -> Option<NonNull<T>> {
// SAFETY: prev is the first field in PointersInner, which is #[repr(C)].
unsafe {
let inner = self.inner.get();
let prev = inner as *const Option<NonNull<T>>;
ptr::read(prev)
}
}
pub(crate) fn get_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:12 | let next = self.get_next();
f.debug_struct("Pointers")
.field("prev", &prev)
.field("next", &next)
.finish()
}
}
#[cfg(any(test, fuzzing))]
#[cfg(not(loom))]
pub(crate) mod tests {
use super::*;
use std::pin::Pin;
#[derive(Debug)]
#[repr(C)]
struct ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:13 | Box::pin(Entry {
pointers: Pointers::new(),
val,
})
}
fn ptr(r: &Pin<Box<Entry>>) -> NonNull<Entry> {
r.as_ref().get_ref().into()
}
fn collect_list(list: &mut LinkedList<&'_ Entry, <&'_ Entry as Link>::Target>) -> Vec<i32> {
let mut ret = vec![];
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:14 | // Deal with mapping a Pin<&mut T> -> Option<NonNull<T>>
assert_eq!(Some($a.as_ref().get_ref().into()), $b)
}};
}
#[test]
fn const_new() {
const _: LinkedList<&Entry, <&Entry as Link>::Target> = LinkedList::new();
}
#[test]
fn push_and_drain() {
let a = entr... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:15 | assert_eq!(5, entry.val);
assert!(list.is_empty());
list.push_front(b.as_ref());
let entry = list.pop_back().unwrap();
assert_eq!(7, entry.val);
assert!(list.is_empty());
assert!(list.pop_back().is_none());
}
#[test]
fn remove_by_address() {
let a ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | }
unsafe {
// Remove middle
let mut list = LinkedList::new();
push_all(&mut list, &[c.as_ref(), b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
assert_ptr_eq!(b, list.head);
assert_ptr_eq... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:17 | push_all(&mut list, &[c.as_ref(), b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&c)).is_some());
assert_clean!(c);
assert!(b.pointers.get_next().is_none());
assert_ptr_eq!(b, list.tail);
let items = collect_list(&mut list);
assert_eq!([7, 5]... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:18 | assert!(list.remove(ptr(&b)).is_some());
assert_clean!(b);
assert_ptr_eq!(a, list.head);
assert_ptr_eq!(a, list.tail);
assert!(a.pointers.get_next().is_none());
assert!(a.pointers.get_prev().is_none());
let items = collect_list(&mut list);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:19 | /// This is a fuzz test. You run it by entering `cargo fuzz run fuzz_linked_list` in CLI in `/tokio/` module.
#[cfg(fuzzing)]
pub fn fuzz_linked_list(ops: &[u8]) {
enum Op {
Push,
Pop,
Remove(usize),
}
use std::collections::VecDeque;
let ops =... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:20 | let v = reference.pop_back();
assert_eq!(v, ll.pop_back().map(|v| v.val));
}
Op::Remove(n) => {
if reference.is_empty() {
assert!(ll.is_empty());
continue;
}
l... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | abc93f615e1fa0bfcd7a2650343bbe562ef95e3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abc93f615e1fa0bfcd7a2650343bbe562ef95e3f/tokio/src/util/linked_list.rs | 761 | 781 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:13 | Box::pin(Entry {
pointers: Pointers::new(),
val,
})
}
fn ptr(r: &Pin<Box<Entry>>) -> NonNull<Entry> {
r.as_ref().get_ref().into()
}
fn collect_list(list: &mut LinkedList<&'_ Entry, <&'_ Entry as Link>::Target>) -> Vec<i32> {
let mut ret = vec![];
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 795754a846a29a0c785d4dadfb7a9136f8aba1ab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/795754a846a29a0c785d4dadfb7a9136f8aba1ab/tokio/src/util/linked_list.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:18 | assert_clean!(b);
assert_ptr_eq!(a, list.head);
assert_ptr_eq!(a, list.tail);
assert!(a.pointers.get_next().is_none());
assert!(a.pointers.get_prev().is_none());
let items = collect_list(&mut list);
assert_eq!([5].to_vec(), items);
}
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 795754a846a29a0c785d4dadfb7a9136f8aba1ab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/795754a846a29a0c785d4dadfb7a9136f8aba1ab/tokio/src/util/linked_list.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:19 | pub fn fuzz_linked_list(ops: &[u8]) {
enum Op {
Push,
Pop,
Remove(usize),
}
use std::collections::VecDeque;
let ops = ops
.iter()
.map(|i| match i % 3u8 {
0 => Op::Push,
1 => Op::Pop,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 795754a846a29a0c785d4dadfb7a9136f8aba1ab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/795754a846a29a0c785d4dadfb7a9136f8aba1ab/tokio/src/util/linked_list.rs | 721 | 778 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:20 | Op::Remove(n) => {
if reference.is_empty() {
assert!(ll.is_empty());
continue;
}
let idx = n % reference.len();
let expect = reference.remove(idx).unwrap();
unsafe {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 795754a846a29a0c785d4dadfb7a9136f8aba1ab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/795754a846a29a0c785d4dadfb7a9136f8aba1ab/tokio/src/util/linked_list.rs | 761 | 778 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:5 | L::pointers(last).as_mut().set_next(None);
Some(L::from_raw(last))
}
}
/// Returns whether the linked list does not contain any node
pub(crate) fn is_empty(&self) -> bool {
if self.head.is_some() {
return false;
}
assert!(self.tail.is_none());
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:6 | .set_prev(L::pointers(node).as_ref().get_prev());
} else {
// This might be the last item in the list
if self.tail != Some(node) {
return None;
}
self.tail = L::pointers(node).as_ref().get_prev();
}
L::pointers(node).as_mut().set_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:7 | impl<L: Link> Default for LinkedList<L, L::Target> {
fn default() -> Self {
Self::new()
}
}
// ===== impl DrainFilter =====
cfg_io_readiness! {
pub(crate) struct DrainFilter<'a, T: Link, F> {
list: &'a mut LinkedList<T, T::Target>,
filter: F,
curr: Option<NonNull<T::Target>... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:8 | // safety: the value is still owned by the linked list.
if (self.filter)(unsafe { &mut *curr.as_ptr() }) {
return unsafe { self.list.remove(curr) };
}
}
None
}
}
}
// ===== impl Pointers =====
impl<T> Pointers<T> {
/// Create... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:9 | ptr::read(next)
}
}
fn set_prev(&mut self, value: Option<NonNull<T>>) {
// SAFETY: prev is the first field in PointersInner, which is #[repr(C)].
unsafe {
let inner = self.inner.get();
let prev = inner as *mut Option<NonNull<T>>;
ptr::write(prev, valu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:10 | #[derive(Debug)]
#[repr(C)]
struct Entry {
pointers: Pointers<Entry>,
val: i32,
}
unsafe impl<'a> Link for &'a Entry {
type Handle = Pin<&'a Entry>;
type Target = Entry;
fn as_raw(handle: &Pin<&'_ Entry>) -> NonNull<Entry> {
NonNull::from(handle.get_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:11 | ret.push(entry.val);
}
ret
}
fn push_all<'a>(
list: &mut LinkedList<&'a Entry, <&'_ Entry as Link>::Target>,
entries: &[Pin<&'a Entry>],
) {
for entry in entries.iter() {
list.push_front(*entry);
}
}
macro_rules! assert_clean {
(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:12 | let mut list = LinkedList::new();
assert!(list.is_empty());
list.push_front(a.as_ref());
assert!(!list.is_empty());
list.push_front(b.as_ref());
list.push_front(c.as_ref());
let items: Vec<i32> = collect_list(&mut list);
assert_eq!([5, 7, 31].to_vec(), items);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:13 | let c = entry(31);
unsafe {
// Remove first
let mut list = LinkedList::new();
push_all(&mut list, &[c.as_ref(), b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
// `a` should be no longer there and can'... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:14 | assert_eq!([31, 7].to_vec(), items);
}
unsafe {
// Remove middle
let mut list = LinkedList::new();
push_all(&mut list, &[c.as_ref(), b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&b)).is_some());
assert_clean!(b);
assert_ptr... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:15 | push_all(&mut list, &[b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
// a should be no longer there and can't be removed twice
assert!(list.remove(ptr(&a)).is_none());
assert_ptr_eq!(b, list.head);
assert_p... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | // Remove last item
let mut list = LinkedList::new();
push_all(&mut list, &[a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
assert!(list.head.is_none());
assert!(list.tail.is_none());
let items = collect_list... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:17 | _ => unreachable!(),
})
.collect::<Vec<_>>();
let mut ll = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
let mut reference = VecDeque::new();
let entries: Vec<_> = (0..ops.len()).map(|i| entry(i as i32)).collect();
for (i, op) in ops.iter().enumerate()... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | d7d5d05333f7970c2d75bfb20371450b5ad838d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7d5d05333f7970c2d75bfb20371450b5ad838d7/tokio/src/util/linked_list.rs | 641 | 684 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:9 | ptr::read(next)
}
}
fn set_prev(&mut self, value: Option<NonNull<T>>) {
// SAFETY: prev is the first field in PointersInner, which is #[repr(C)].
unsafe {
let inner = self.inner.get();
let prev = inner as *mut Option<NonNull<T>>;
ptr::write(prev, valu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/util/linked_list.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | // Remove last item
let mut list = LinkedList::new();
push_all(&mut list, &[a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
assert!(list.head.is_none());
assert!(list.tail.is_none());
let items = collect_list... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:17 | Pop,
Remove(usize),
}
let ops = ops
.iter()
.map(|i| match i % 3 {
0 => Op::Push,
1 => Op::Pop,
2 => Op::Remove(i / 3),
_ => unreachable!(),
})
.collect::<Vec<_>>();
let ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/util/linked_list.rs | 641 | 694 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:18 | }
let idx = n % reference.len();
let expect = reference.remove(idx).unwrap();
unsafe {
let entry = ll.remove(ptr(&entries[expect as usize])).unwrap();
assert_eq!(expect, entry.val);
}
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/util/linked_list.rs | 681 | 694 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:3 | /// hence be given the `noalias` attribute if we were to do such an access.
/// As an alternative to accessing the fields directly, the `Pointers` type
/// provides getters and setters for the two fields, and those are implemented
/// using raw pointer casts and offsets, which is valid since the struct is
/// #[repr(C)... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/util/linked_list.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:4 | }
}
impl<L: Link> LinkedList<L, L::Target> {
/// Adds an element first in the list.
pub(crate) fn push_front(&mut self, val: L::Handle) {
// The value should not be dropped, it is being inserted into the list
let val = ManuallyDrop::new(val);
let ptr = L::as_raw(&*val);
assert_n... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/util/linked_list.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | // Remove last item
let mut list = LinkedList::new();
push_all(&mut list, &[a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
assert!(list.head.is_none());
assert!(list.tail.is_none());
let items = collect_list... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | // Remove last item
let mut list = LinkedList::new();
push_all(&mut list, &[a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
assert!(list.head.is_none());
assert!(list.tail.is_none());
let items = collect_list... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | // Remove last item
let mut list = LinkedList::new();
push_all(&mut list, &[a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
assert!(list.head.is_none());
assert!(list.tail.is_none());
let items = collect_list... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:17 | Remove(usize),
}
let ops = ops
.iter()
.map(|i| match i % 3 {
0 => Op::Push,
1 => Op::Pop,
2 => Op::Remove(i / 3),
_ => unreachable!(),
})
.collect::<Vec<_>>();
let mut ll = LinkedLi... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/linked_list.rs | 641 | 693 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:18 | let idx = n % reference.len();
let expect = reference.remove(idx).unwrap();
unsafe {
let entry = ll.remove(ptr(&entries[expect as usize])).unwrap();
assert_eq!(expect, entry.val);
}
}
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/linked_list.rs | 681 | 693 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:1 | #![cfg_attr(not(feature = "full"), allow(dead_code))]
//! An intrusive double linked list of data.
//!
//! The data structure supports tracking pinned nodes. Most of the data
//! structure's APIs are `unsafe` as they require the caller to ensure the
//! specified node is actually contained by the list.
use core::cell... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:2 | /// other words, when a node is inserted, the value will not be moved as long as
/// it is stored in the list.
pub(crate) unsafe trait Link {
/// Handle to the list entry.
///
/// This is usually a pointer-ish type.
type Handle;
/// Node type.
type Target;
/// Convert the handle to a raw p... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:3 | /// <https://github.com/rust-lang/rust/pull/82834>
#[repr(C)]
struct PointersInner<T> {
/// The previous node in the list. null if there is no previous node.
///
/// This field is accessed through pointer manipulation, so it is not dead code.
#[allow(dead_code)]
prev: Option<NonNull<T>>,
/// Th... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:4 | let val = ManuallyDrop::new(val);
let ptr = L::as_raw(&*val);
assert_ne!(self.head, Some(ptr));
unsafe {
L::pointers(ptr).as_mut().set_next(self.head);
L::pointers(ptr).as_mut().set_prev(None);
if let Some(head) = self.head {
L::pointers(head)... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:5 | pub(crate) fn is_empty(&self) -> bool {
if self.head.is_some() {
return false;
}
assert!(self.tail.is_none());
true
}
/// Removes the specified node from the list
///
/// # Safety
///
/// The caller **must** ensure that `node` is currently contained ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:6 | self.tail = L::pointers(node).as_ref().get_prev();
}
L::pointers(node).as_mut().set_next(None);
L::pointers(node).as_mut().set_prev(None);
Some(L::from_raw(node))
}
}
impl<L: Link> fmt::Debug for LinkedList<L, L::Target> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Resu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:7 | cfg_io_readiness! {
pub(crate) struct DrainFilter<'a, T: Link, F> {
list: &'a mut LinkedList<T, T::Target>,
filter: F,
curr: Option<NonNull<T::Target>>,
}
impl<T: Link> LinkedList<T, T::Target> {
pub(crate) fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F>
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:8 | None
}
}
}
// ===== impl Pointers =====
impl<T> Pointers<T> {
/// Create a new set of empty pointers
pub(crate) fn new() -> Pointers<T> {
Pointers {
inner: UnsafeCell::new(PointersInner {
prev: None,
next: None,
_pin: PhantomPinne... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:9 | let inner = self.inner.get();
let prev = inner as *mut Option<NonNull<T>>;
ptr::write(prev, value);
}
}
fn set_next(&mut self, value: Option<NonNull<T>>) {
// SAFETY: next is the second field in PointersInner, which is #[repr(C)].
unsafe {
let inner = ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:10 | unsafe impl<'a> Link for &'a Entry {
type Handle = Pin<&'a Entry>;
type Target = Entry;
fn as_raw(handle: &Pin<&'_ Entry>) -> NonNull<Entry> {
NonNull::from(handle.get_ref())
}
unsafe fn from_raw(ptr: NonNull<Entry>) -> Pin<&'a Entry> {
Pin::new_unchecke... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:11 | entries: &[Pin<&'a Entry>],
) {
for entry in entries.iter() {
list.push_front(*entry);
}
}
macro_rules! assert_clean {
($e:ident) => {{
assert!($e.pointers.get_next().is_none());
assert!($e.pointers.get_prev().is_none());
}};
}
ma... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:12 | let items: Vec<i32> = collect_list(&mut list);
assert_eq!([5, 7, 31].to_vec(), items);
assert!(list.is_empty());
}
#[test]
fn push_pop_push_pop() {
let a = entry(5);
let b = entry(7);
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
li... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:13 | assert_clean!(a);
// `a` should be no longer there and can't be removed twice
assert!(list.remove(ptr(&a)).is_none());
assert!(!list.is_empty());
assert!(list.remove(ptr(&b)).is_some());
assert_clean!(b);
// `b` should be no longer there and can't... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:14 | assert!(list.remove(ptr(&b)).is_some());
assert_clean!(b);
assert_ptr_eq!(c, a.pointers.get_next());
assert_ptr_eq!(a, c.pointers.get_prev());
let items = collect_list(&mut list);
assert_eq!([31, 5].to_vec(), items);
}
unsafe {
/... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:15 | assert_ptr_eq!(b, list.head);
assert_ptr_eq!(b, list.tail);
assert!(b.pointers.get_next().is_none());
assert!(b.pointers.get_prev().is_none());
let items = collect_list(&mut list);
assert_eq!([7].to_vec(), items);
}
unsafe {
// R... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | assert!(list.head.is_none());
assert!(list.tail.is_none());
let items = collect_list(&mut list);
assert!(items.is_empty());
}
unsafe {
// Remove missing
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
list.pu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:17 | 2 => Op::Remove(i / 3),
_ => unreachable!(),
})
.collect::<Vec<_>>();
let mut ll = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
let mut reference = VecDeque::new();
let entries: Vec<_> = (0..ops.len()).map(|i| entry(i as i32)).collect();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/linked_list.rs | 641 | 685 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:6 | self.tail = L::pointers(node).as_ref().get_prev();
}
L::pointers(node).as_mut().set_next(None);
L::pointers(node).as_mut().set_prev(None);
Some(L::from_raw(node))
}
}
impl<L: Link> fmt::Debug for LinkedList<L, L::Target> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Resu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:7 | cfg_io_readiness! {
pub(crate) struct DrainFilter<'a, T: Link, F> {
list: &'a mut LinkedList<T, T::Target>,
filter: F,
curr: Option<NonNull<T::Target>>,
}
impl<T: Link> LinkedList<T, T::Target> {
pub(crate) fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F>
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:8 | }
}
}
// ===== impl Pointers =====
impl<T> Pointers<T> {
/// Create a new set of empty pointers
pub(crate) fn new() -> Pointers<T> {
Pointers {
inner: UnsafeCell::new(PointersInner {
prev: None,
next: None,
_pin: PhantomPinned,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:9 | let prev = inner as *mut Option<NonNull<T>>;
ptr::write(prev, value);
}
}
fn set_next(&mut self, value: Option<NonNull<T>>) {
// SAFETY: next is the second field in PointersInner, which is #[repr(C)].
unsafe {
let inner = self.inner.get();
let prev = i... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:10 | type Handle = Pin<&'a Entry>;
type Target = Entry;
fn as_raw(handle: &Pin<&'_ Entry>) -> NonNull<Entry> {
NonNull::from(handle.get_ref())
}
unsafe fn from_raw(ptr: NonNull<Entry>) -> Pin<&'a Entry> {
Pin::new_unchecked(&*ptr.as_ptr())
}
unsafe f... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:11 | ) {
for entry in entries.iter() {
list.push_front(*entry);
}
}
macro_rules! assert_clean {
($e:ident) => {{
assert!($e.pointers.get_next().is_none());
assert!($e.pointers.get_prev().is_none());
}};
}
macro_rules! assert_ptr_eq {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:12 | assert_eq!([5, 7, 31].to_vec(), items);
assert!(list.is_empty());
}
#[test]
fn push_pop_push_pop() {
let a = entry(5);
let b = entry(7);
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
list.push_front(a.as_ref());
let entry = list.po... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:13 | // `a` should be no longer there and can't be removed twice
assert!(list.remove(ptr(&a)).is_none());
assert!(!list.is_empty());
assert!(list.remove(ptr(&b)).is_some());
assert_clean!(b);
// `b` should be no longer there and can't be removed twice
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:15 | assert_ptr_eq!(b, list.head);
assert_ptr_eq!(b, list.tail);
assert!(b.pointers.get_next().is_none());
assert!(b.pointers.get_prev().is_none());
let items = collect_list(&mut list);
assert_eq!([7].to_vec(), items);
}
unsafe {
// R... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | assert!(list.tail.is_none());
let items = collect_list(&mut list);
assert!(items.is_empty());
}
unsafe {
// Remove missing
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
list.push_front(b.as_ref());
list.pus... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:15 | assert_ptr_eq!(b, list.head);
assert_ptr_eq!(b, list.tail);
assert!(b.pointers.get_next().is_none());
assert!(b.pointers.get_prev().is_none());
let items = collect_list(&mut list);
assert_eq!([7].to_vec(), items);
}
unsafe {
// R... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/linked_list.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | assert!(list.tail.is_none());
let items = collect_list(&mut list);
assert!(items.is_empty());
}
unsafe {
// Remove missing
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
list.push_front(b.as_ref());
list.pus... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:17 | })
.collect::<Vec<_>>();
let mut ll = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
let mut reference = VecDeque::new();
let entries: Vec<_> = (0..ops.len()).map(|i| entry(i as i32)).collect();
for (i, op) in ops.iter().enumerate() {
match op {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/linked_list.rs | 641 | 683 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:1 | #![cfg_attr(not(feature = "full"), allow(dead_code))]
//! An intrusive double linked list of data
//!
//! The data structure supports tracking pinned nodes. Most of the data
//! structure's APIs are `unsafe` as they require the caller to ensure the
//! specified node is actually contained by the list.
use core::cell:... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | e2589a0e401e27457618920e66caa0f14e9a69ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/util/linked_list.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:2 | /// other words, when a node is inserted, the value will not be moved as long as
/// it is stored in the list.
pub(crate) unsafe trait Link {
/// Handle to the list entry.
///
/// This is usually a pointer-ish type.
type Handle;
/// Node type
type Target;
/// Convert the handle to a raw po... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | e2589a0e401e27457618920e66caa0f14e9a69ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/util/linked_list.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:6 | self.tail = L::pointers(node).as_ref().get_prev();
}
L::pointers(node).as_mut().set_next(None);
L::pointers(node).as_mut().set_prev(None);
Some(L::from_raw(node))
}
}
impl<L: Link> fmt::Debug for LinkedList<L, L::Target> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Resu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:7 | cfg_rt_multi_thread! {
pub(crate) struct Iter<'a, T: Link> {
curr: Option<NonNull<T::Target>>,
_p: core::marker::PhantomData<&'a T>,
}
impl<L: Link> LinkedList<L, L::Target> {
pub(crate) fn iter(&self) -> Iter<'_, L> {
Iter {
curr: self.head,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:8 | where
F: FnMut(&mut T::Target) -> bool,
{
let curr = self.head;
DrainFilter {
curr,
filter,
list: self,
}
}
}
impl<'a, T, F> Iterator for DrainFilter<'a, T, F>
where
T: Link,
F: F... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:9 | Pointers {
inner: UnsafeCell::new(PointersInner {
prev: None,
next: None,
_pin: PhantomPinned,
}),
}
}
fn get_prev(&self) -> Option<NonNull<T>> {
// SAFETY: prev is the first field in PointersInner, which is #[repr(C)].
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:10 | let next = prev.add(1);
ptr::write(next, value);
}
}
}
impl<T> fmt::Debug for Pointers<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let prev = self.get_prev();
let next = self.get_next();
f.debug_struct("Pointers")
.field("prev", &prev)... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:11 | }
unsafe fn pointers(mut target: NonNull<Entry>) -> NonNull<Pointers<Entry>> {
NonNull::from(&mut target.as_mut().pointers)
}
}
fn entry(val: i32) -> Pin<Box<Entry>> {
Box::pin(Entry {
pointers: Pointers::new(),
val,
})
}
fn ptr(r: &... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:12 | assert!($e.pointers.get_prev().is_none());
}};
}
macro_rules! assert_ptr_eq {
($a:expr, $b:expr) => {{
// Deal with mapping a Pin<&mut T> -> Option<NonNull<T>>
assert_eq!(Some($a.as_ref().get_ref().into()), $b)
}};
}
#[test]
fn const_new() {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:13 | let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
list.push_front(a.as_ref());
let entry = list.pop_back().unwrap();
assert_eq!(5, entry.val);
assert!(list.is_empty());
list.push_front(b.as_ref());
let entry = list.pop_back().unwrap();
asse... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:14 | assert!(list.remove(ptr(&c)).is_some());
assert_clean!(c);
// `b` should be no longer there and can't be removed twice
assert!(list.remove(ptr(&c)).is_none());
assert!(list.is_empty());
}
unsafe {
// Remove middle
let mut list = Li... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:15 | unsafe {
// Remove last
// Remove middle
let mut list = LinkedList::new();
push_all(&mut list, &[c.as_ref(), b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&c)).is_some());
assert_clean!(c);
assert!(b.pointers.get_next().is_none()... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | unsafe {
// Remove last of two
let mut list = LinkedList::new();
push_all(&mut list, &[b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&b)).is_some());
assert_clean!(b);
assert_ptr_eq!(a, list.head);
assert_ptr_eq!(a, list.tail);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:17 | list.push_front(b.as_ref());
list.push_front(a.as_ref());
assert!(list.remove(ptr(&c)).is_none());
}
}
#[test]
fn iter() {
let a = entry(5);
let b = entry(7);
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new();
assert_eq!(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:18 | }
let ops = ops
.iter()
.map(|i| match i % 3 {
0 => Op::Push,
1 => Op::Pop,
2 => Op::Remove(i / 3),
_ => unreachable!(),
})
.collect::<Vec<_>>();
let mut ll = LinkedList::<&Entry, <&Entry as... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/src/util/linked_list.rs | 681 | 732 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:1 | #![cfg_attr(not(feature = "full"), allow(dead_code))]
//! An intrusive double linked list of data
//!
//! The data structure supports tracking pinned nodes. Most of the data
//! structure's APIs are `unsafe` as they require the caller to ensure the
//! specified node is actually contained by the list.
use core::cell:... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c4b6b130f33532e891e1021381b203f1bbced086 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c4b6b130f33532e891e1021381b203f1bbced086/tokio/src/util/linked_list.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:2 | /// other words, when a node is inserted, the value will not be moved as long as
/// it is stored in the list.
pub(crate) unsafe trait Link {
/// Handle to the list entry.
///
/// This is usually a pointer-ish type.
type Handle;
/// Node type
type Target;
/// Convert the handle to a raw po... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c4b6b130f33532e891e1021381b203f1bbced086 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c4b6b130f33532e891e1021381b203f1bbced086/tokio/src/util/linked_list.rs | 41 | 100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.