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:3
#[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>>, /// The next node in the list. null if there is no previo...
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
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
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).as_mut().set_prev(Some(ptr)); ...
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
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
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 by /// `self` or not contained by any other ...
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
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
} 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::Result { f.debug_struct("LinkedList") .fiel...
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
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
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, _p: core::marker::Phant...
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
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:8
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: FnMut(&mut T::Targe...
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
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
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)]. unsafe { ...
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
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
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) .field("next", &next) ...
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
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: &Pin<Box<Ent...
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
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
}}; } 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() { const _: LinkedList<&Entry, <&Entry as Link>::Targe...
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
441
500
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
c4b6b130f33532e891e1021381b203f1bbced086
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c4b6b130f33532e891e1021381b203f1bbced086/tokio/src/util/linked_list.rs
521
580
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
c4b6b130f33532e891e1021381b203f1bbced086
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c4b6b130f33532e891e1021381b203f1bbced086/tokio/src/util/linked_list.rs
601
660
tokio-rs/tokio:tokio/src/util/linked_list.rs:17
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!(0, list.iter().count()); list.pu...
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
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 Link>::Tar...
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
681
731
tokio-rs/tokio:tokio/src/util/linked_list.rs:19
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
c4b6b130f33532e891e1021381b203f1bbced086
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c4b6b130f33532e891e1021381b203f1bbced086/tokio/src/util/linked_list.rs
721
731
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
fee76ea7d5e1f24a155d3fcd319aa2893a095c4f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fee76ea7d5e1f24a155d3fcd319aa2893a095c4f/tokio/src/util/linked_list.rs
41
100
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
#[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>>, /// The next node in the list. null if there is no previo...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
fee76ea7d5e1f24a155d3fcd319aa2893a095c4f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fee76ea7d5e1f24a155d3fcd319aa2893a095c4f/tokio/src/util/linked_list.rs
81
140
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::fmt; ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
1
60
tokio-rs/tokio:tokio/src/util/linked_list.rs:2
/// 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 pointer without consuming the handle fn as_raw(handle: &Self::Handle) -> NonNul...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
41
100
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
_marker: PhantomData, } } } 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 ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
L::pointers(last).as_mut().prev = None; L::pointers(last).as_mut().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; ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
// This might be the last item in the list if self.tail != Some(node) { return None; } self.tail = L::pointers(node).as_ref().prev; } L::pointers(node).as_mut().next = None; L::pointers(node).as_mut().prev = None; Some(L::from_raw(no...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
} } // ===== impl Iter ===== 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 { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
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> where F: FnMut(&mut T::Target) -> bool, { let curr = self.head; DrainFilter { cur...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/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 { prev: None, next: None, } } } impl<T> fmt::Debug for Pointers<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
} unsafe fn from_raw(ptr: NonNull<Entry>) -> Pin<&'a Entry> { Pin::new(&*ptr.as_ptr()) } unsafe fn pointers(mut target: NonNull<Entry>) -> NonNull<Pointers<Entry>> { NonNull::from(&mut target.as_mut().pointers) } } fn entry(val: i32) -> Pin<Box<Entry>> ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
macro_rules! assert_clean { ($e:ident) => {{ assert!($e.pointers.next.is_none()); assert!($e.pointers.prev.is_none()); }}; } macro_rules! assert_ptr_eq { ($a:expr, $b:expr) => {{ // Deal with mapping a Pin<&mut T> -> Option<NonNull<T>> ass...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
#[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.pop_back().unwrap(); assert_eq!(5, entry.val); assert!(list.is_empty());...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
assert_clean!(b); // `b` should be no longer there and can't be removed twice assert!(list.remove(ptr(&b)).is_none()); assert!(!list.is_empty()); assert!(list.remove(ptr(&c)).is_some()); assert_clean!(c); // `b` should be no longer there and can't...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
let items = collect_list(&mut list); assert_eq!([31, 5].to_vec(), items); } 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.remov...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
481
540
tokio-rs/tokio:tokio/src/util/linked_list.rs:14
let items = collect_list(&mut list); assert_eq!([7].to_vec(), items); } 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()); as...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
521
580
tokio-rs/tokio:tokio/src/util/linked_list.rs:15
unsafe { // Remove missing let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new(); list.push_front(b.as_ref()); list.push_front(a.as_ref()); assert!(list.remove(ptr(&c)).is_none()); } } #[test] fn iter() { let a = e...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
561
620
tokio-rs/tokio:tokio/src/util/linked_list.rs:16
enum Op { Push, Pop, Remove(usize), } let ops = ops .iter() .map(|i| match i % 3 { 0 => Op::Push, 1 => Op::Pop, 2 => Op::Remove(i / 3), _ => unreachable!(), }) ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
601
656
tokio-rs/tokio:tokio/src/util/linked_list.rs:17
assert!(ll.is_empty()); continue; } let idx = n % reference.len(); let expect = reference.remove(idx).unwrap(); unsafe { let entry = ll.remove(ptr(&entries[expect as usize])).unwrap(); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/util/linked_list.rs
641
656
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
_marker: PhantomData, } } } 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 ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
L::pointers(last).as_mut().prev = None; L::pointers(last).as_mut().next = None; Some(L::from_raw(last)) } } /// Returns whether the linked list doesn not contain any node pub(crate) fn is_empty(&self) -> bool { if self.head.is_some() { return false; ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
// This might be the last item in the list if self.tail != Some(node) { return None; } self.tail = L::pointers(node).as_ref().prev; } L::pointers(node).as_mut().next = None; L::pointers(node).as_mut().prev = None; Some(L::from_raw(no...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
24d0a0cfa8916eaef17f40f044d978aa3904d654
github
async-runtime
https://github.com/tokio-rs/tokio/blob/24d0a0cfa8916eaef17f40f044d978aa3904d654/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
} } // ===== impl Iter ===== cfg_rt_threaded! { 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 { cu...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
24d0a0cfa8916eaef17f40f044d978aa3904d654
github
async-runtime
https://github.com/tokio-rs/tokio/blob/24d0a0cfa8916eaef17f40f044d978aa3904d654/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
// This might be the last item in the list if self.tail != Some(node) { return None; } self.tail = L::pointers(node).as_ref().prev; } L::pointers(node).as_mut().next = None; L::pointers(node).as_mut().prev = None; Some(L::from_raw(no...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
891de3271dc3545fb09162e578251e9977d9789c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/891de3271dc3545fb09162e578251e9977d9789c/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
_marker: PhantomData, } } } 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 ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
} L::pointers(last).as_mut().prev = None; L::pointers(last).as_mut().next = None; Some(L::from_raw(last)) } } /// Returns whether the linked list doesn not contain any node pub(crate) fn is_empty(&self) -> bool { if self.head.is_some() { ret...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
} else { // This might be the last item in the list if self.tail != Some(node) { return None; } self.tail = L::pointers(node).as_ref().prev; } L::pointers(node).as_mut().next = None; L::pointers(node).as_mut().prev = None; ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
Self::new() } } // ===== impl Iter ===== cfg_rt_threaded! { 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 { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
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> where F: FnMut(&mut T::Target) -> bool, { let curr = self.head; DrainFilter { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/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 { prev: None, next: None, } } } impl<T> fmt::Debug for Pointers<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
NonNull::from(handle.get_ref()) } unsafe fn from_raw(ptr: NonNull<Entry>) -> Pin<&'a Entry> { Pin::new(&*ptr.as_ptr()) } unsafe fn pointers(mut target: NonNull<Entry>) -> NonNull<Pointers<Entry>> { NonNull::from(&mut target.as_mut().pointers) } } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
} macro_rules! assert_clean { ($e:ident) => {{ assert!($e.pointers.next.is_none()); assert!($e.pointers.prev.is_none()); }}; } macro_rules! assert_ptr_eq { ($a:expr, $b:expr) => {{ // Deal with mapping a Pin<&mut T> -> Option<NonNull<T>> ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
#[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.pop_back().unwrap(); assert_eq!(5, entry.val); assert!(list.is_empty());...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
assert!(list.remove(ptr(&b)).is_some()); assert_clean!(b); // `b` should be no longer there and can't be removed twice assert!(list.remove(ptr(&b)).is_none()); assert!(!list.is_empty()); assert!(list.remove(ptr(&c)).is_some()); assert_clean!(c); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
assert_ptr_eq!(a, c.pointers.prev); let items = collect_list(&mut list); assert_eq!([31, 5].to_vec(), items); } unsafe { // Remove last // Remove middle let mut list = LinkedList::new(); push_all(&mut list, &[c.as_ref(), b.as_ref...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
481
540
tokio-rs/tokio:tokio/src/util/linked_list.rs:14
assert!(b.pointers.prev.is_none()); let items = collect_list(&mut list); assert_eq!([7].to_vec(), items); } unsafe { // Remove last of two let mut list = LinkedList::new(); push_all(&mut list, &[b.as_ref(), a.as_ref()]); assert!...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
521
580
tokio-rs/tokio:tokio/src/util/linked_list.rs:15
unsafe { // Remove missing let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new(); list.push_front(b.as_ref()); list.push_front(a.as_ref()); assert!(list.remove(ptr(&c)).is_none()); } } #[test] fn iter() { let a = e...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
561
620
tokio-rs/tokio:tokio/src/util/linked_list.rs:16
#[derive(Debug)] enum Op { Push, Pop, Remove(usize), } let ops = ops .iter() .map(|i| match i % 3 { 0 => Op::Push, 1 => Op::Pop, 2 => Op::Remove(i / 3), _ => unreachable!(...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
601
657
tokio-rs/tokio:tokio/src/util/linked_list.rs:17
if reference.is_empty() { assert!(ll.is_empty()); continue; } let idx = n % reference.len(); let expect = reference.remove(idx).unwrap(); unsafe { let entry = ll.remo...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/util/linked_list.rs
641
657
tokio-rs/tokio:tokio/src/util/linked_list.rs:1
//! 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::fmt; use core::marker::PhantomData; use core::mem::ManuallyD...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
1
60
tokio-rs/tokio:tokio/src/util/linked_list.rs:2
/// Handle to the list entry. /// /// This is usually a pointer-ish type. type Handle; /// Node type type Target; /// Convert the handle to a raw pointer without consuming the handle fn as_raw(handle: &Self::Handle) -> NonNull<Self::Target>; /// Convert the raw pointer to a handle ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
41
100
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
} } 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
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
L::pointers(last).as_mut().prev = None; L::pointers(last).as_mut().next = None; Some(L::from_raw(last)) } } /// Returns whether the linked list doesn not contain any node pub(crate) fn is_empty(&self) -> bool { if self.head.is_some() { return false; ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
if self.tail != Some(node) { return None; } self.tail = L::pointers(node).as_ref().prev; } L::pointers(node).as_mut().next = None; L::pointers(node).as_mut().prev = None; Some(L::from_raw(node)) } } impl<L: Link> fmt::Debug for LinkedList<L...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
} // ===== impl Iter ===== cfg_rt_threaded! { 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...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
} impl<T: Link> LinkedList<T, T::Target> { pub(crate) fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F> where F: FnMut(&mut T::Target) -> bool, { let curr = self.head; DrainFilter { curr, filter, ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:8
impl<T> Pointers<T> { /// Create a new set of empty pointers pub(crate) fn new() -> Pointers<T> { Pointers { prev: None, next: None, } } } impl<T> fmt::Debug for Pointers<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Poin...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
unsafe fn from_raw(ptr: NonNull<Entry>) -> Pin<&'a Entry> { Pin::new(&*ptr.as_ptr()) } unsafe fn pointers(mut target: NonNull<Entry>) -> NonNull<Pointers<Entry>> { NonNull::from(&mut target.as_mut().pointers) } } fn entry(val: i32) -> Pin<Box<Entry>> { B...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
macro_rules! assert_clean { ($e:ident) => {{ assert!($e.pointers.next.is_none()); assert!($e.pointers.prev.is_none()); }}; } macro_rules! assert_ptr_eq { ($a:expr, $b:expr) => {{ // Deal with mapping a Pin<&mut T> -> Option<NonNull<T>> ass...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
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.pop_back().unwrap(); assert_eq!(5, entry.val); assert!(list.is_empty()); li...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
// `b` should be no longer there and can't be removed twice assert!(list.remove(ptr(&b)).is_none()); 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 ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:14
let items = collect_list(&mut list); assert_eq!([7].to_vec(), items); } 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()); as...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
521
580
tokio-rs/tokio:tokio/src/util/linked_list.rs:15
// Remove missing let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new(); 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 ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
561
620
tokio-rs/tokio:tokio/src/util/linked_list.rs:16
Push, 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<_>...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
601
655
tokio-rs/tokio:tokio/src/util/linked_list.rs:17
continue; } 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
afe535283c68dec40c5fc7a810445e8c2380880f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/afe535283c68dec40c5fc7a810445e8c2380880f/tokio/src/util/linked_list.rs
641
655
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
if self.tail != Some(node) { return None; } self.tail = L::pointers(node).as_ref().prev; } L::pointers(node).as_mut().next = None; L::pointers(node).as_mut().prev = None; Some(L::from_raw(node)) } } impl<L: Link> fmt::Debug for LinkedList<L...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
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, _p: core::marker::Phant...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
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: FnMut(&mut T::Targe...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:8
prev: None, next: None, } } } impl<T> fmt::Debug for Pointers<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Pointers") .field("prev", &self.prev) .field("next", &self.next) .finish() } } #[cfg(test)] #[cfg(no...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
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: &Pin<Box<Ent...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
} 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() { const _: LinkedList<&Entry, <&Entry as Link>::Target> = Lin...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
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(); assert_eq!(7, entry.val); assert!(list.is_empty()); assert!(list.p...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
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 = LinkedList::new(); push_all(&mut list, &[c...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
// 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.next.is_none()); assert_ptr_e...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
481
540
tokio-rs/tokio:tokio/src/util/linked_list.rs:14
// 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); assert!(...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
521
580
tokio-rs/tokio:tokio/src/util/linked_list.rs:15
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!(0, list.iter().count()); list.push_front(a.as_ref()); list.push_fr...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
561
620
tokio-rs/tokio:tokio/src/util/linked_list.rs:17
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
cf025ba45f68934ae2138bb75ee2a5ee50506d1b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/util/linked_list.rs
641
650
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
} } 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
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
L::pointers(last).as_mut().prev = None; L::pointers(last).as_mut().next = None; Some(L::from_raw(last)) } } /// Returns whether the linked list doesn not contain any node #[cfg_attr(any(feature = "udp", feature = "uds"), allow(unused))] pub(crate) fn is_empty(&self) -> ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
// This might be the last item in the list if self.tail != Some(node) { return None; } self.tail = L::pointers(node).as_ref().prev; } L::pointers(node).as_mut().next = None; L::pointers(node).as_mut().prev = None; Some(L::from_raw(no...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
// ===== impl Iter ===== cfg_rt_threaded! { 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: s...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
impl<T: Link> LinkedList<T, T::Target> { pub(crate) fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F> where F: FnMut(&mut T::Target) -> bool, { let curr = self.head; DrainFilter { curr, filter, li...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
unsafe fn from_raw(ptr: NonNull<Entry>) -> Pin<&'a Entry> { Pin::new(&*ptr.as_ptr()) } unsafe fn pointers(mut target: NonNull<Entry>) -> NonNull<Pointers<Entry>> { NonNull::from(&mut target.as_mut().pointers) } } fn entry(val: i32) -> Pin<Box<Entry>> { B...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
($e:ident) => {{ assert!($e.pointers.next.is_none()); assert!($e.pointers.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().i...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
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.pop_back().unwrap(); assert_eq!(5, entry.val); assert!(list.is_empty()); list.push_front(b.as_ref()); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
assert!(list.remove(ptr(&b)).is_none()); 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_emp...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
assert_eq!([31, 5].to_vec(), items); } 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!(...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
481
540
tokio-rs/tokio:tokio/src/util/linked_list.rs:14
assert_eq!([7].to_vec(), items); } 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, li...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
521
580
tokio-rs/tokio:tokio/src/util/linked_list.rs:15
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new(); 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...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/linked_list.rs
561
620
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
} } 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
20ef28655354ae729a4af2098426a413e3f4d769
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20ef28655354ae729a4af2098426a413e3f4d769/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
L::pointers(last).as_mut().next = None; Some(L::from_raw(last)) } } /// Returns whether the linked list doesn 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
20ef28655354ae729a4af2098426a413e3f4d769
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20ef28655354ae729a4af2098426a413e3f4d769/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
return None; } self.tail = L::pointers(node).as_ref().prev; } L::pointers(node).as_mut().next = None; L::pointers(node).as_mut().prev = None; Some(L::from_raw(node)) } } impl<L: Link> fmt::Debug for LinkedList<L, L::Target> { fn fmt(&self, f: &mut fmt:...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
20ef28655354ae729a4af2098426a413e3f4d769
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20ef28655354ae729a4af2098426a413e3f4d769/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
impl<L: Link> LinkedList<L, L::Target> { pub(crate) fn iter(&self) -> Iter<'_, L> { Iter { curr: self.head, _p: core::marker::PhantomData, } } } impl<'a, T: Link> Iterator for Iter<'a, T> { type Item = &'a T::Target; fn ne...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
20ef28655354ae729a4af2098426a413e3f4d769
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20ef28655354ae729a4af2098426a413e3f4d769/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
.field("next", &self.next) .finish() } } #[cfg(test)] #[cfg(not(loom))] mod tests { use super::*; use std::pin::Pin; #[derive(Debug)] struct Entry { pointers: Pointers<Entry>, val: i32, } unsafe impl<'a> Link for &'a Entry { type Handle = Pin<&'a Entry...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
20ef28655354ae729a4af2098426a413e3f4d769
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20ef28655354ae729a4af2098426a413e3f4d769/tokio/src/util/linked_list.rs
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:8
} 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![]; while let Some(entry) = list.pop_back() { ret.push(entry.val); } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
20ef28655354ae729a4af2098426a413e3f4d769
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20ef28655354ae729a4af2098426a413e3f4d769/tokio/src/util/linked_list.rs
281
340