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:9
fn const_new() { const _: LinkedList<&Entry, <&Entry as Link>::Target> = LinkedList::new(); } #[test] fn push_and_drain() { let a = entry(5); let b = entry(7); let c = entry(31); let mut list = LinkedList::new(); assert!(list.is_empty()); list.push_...
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
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
assert_eq!(7, entry.val); assert!(list.is_empty()); assert!(list.pop_back().is_none()); } #[test] fn remove_by_address() { let a = entry(5); let b = entry(7); let c = entry(31); unsafe { // Remove first let mut list = LinkedList::new...
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
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
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!(c, b.pointers.next); assert_ptr_eq!(b, c.pointers.prev); let items = collect_list...
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
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
assert_ptr_eq!(b, list.tail); let items = collect_list(&mut list); assert_eq!([7, 5].to_vec(), items); } unsafe { // Remove first of two let mut list = LinkedList::new(); push_all(&mut list, &[b.as_ref(), a.as_ref()]); assert!(l...
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
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
assert_ptr_eq!(a, list.tail); assert!(a.pointers.next.is_none()); assert!(a.pointers.prev.is_none()); let items = collect_list(&mut list); assert_eq!([5].to_vec(), items); } unsafe { // Remove last item let mut list = LinkedList:...
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
481
540
tokio-rs/tokio:tokio/src/util/linked_list.rs:14
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new(); assert_eq!(0, list.iter().count()); list.push_front(a.as_ref()); list.push_front(b.as_ref()); let mut i = list.iter(); assert_eq!(7, i.next().unwrap().val); assert_eq!(5, i.next().unwrap().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
521
580
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
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/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); as...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/util/linked_list.rs
81
140
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
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/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; ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
.field("prev", &self.prev) .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 Entr...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/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
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
#[test] fn const_new() { const _: LinkedList<&Entry, <&Entry as Link>::Target> = LinkedList::new(); } #[test] fn push_and_drain() { let a = entry(5); let b = entry(7); let c = entry(31); let mut list = LinkedList::new(); assert!(list.is_empty()); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
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 = entry(5); let b = entry(7); let c = entry(31); unsafe { // Remove fi...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
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!(c, b.pointers.next); assert_ptr_eq!(b, c.pointers.prev); let items = collect_list...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
assert!(b.pointers.next.is_none()); assert_ptr_eq!(b, list.tail); let items = collect_list(&mut list); assert_eq!([7, 5].to_vec(), items); } unsafe { // Remove first of two let mut list = LinkedList::new(); push_all(&mut list, &[...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
assert_ptr_eq!(a, list.head); assert_ptr_eq!(a, list.tail); assert!(a.pointers.next.is_none()); assert!(a.pointers.prev.is_none()); let items = collect_list(&mut list); assert_eq!([5].to_vec(), items); } unsafe { // Remove last i...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/util/linked_list.rs
481
540
tokio-rs/tokio:tokio/src/util/linked_list.rs:14
let mut list = LinkedList::<&Entry, <&Entry as Link>::Target>::new(); assert_eq!(0, list.iter().count()); list.push_front(a.as_ref()); list.push_front(b.as_ref()); let mut i = list.iter(); assert_eq!(7, i.next().unwrap().val); assert_eq!(5, i.next().unwrap().val); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/util/linked_list.rs
521
580
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::mem::ManuallyDrop; use core::ptr::NonNull; /...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
1
60
tokio-rs/tokio:tokio/src/util/linked_list.rs:2
/// 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 unsafe fn from_raw(ptr: NonNull<Self::Target>) -> Self::Handle; /// Return the pointers for a node...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
41
100
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
let val = ManuallyDrop::new(val); let ptr = T::as_raw(&*val); assert_ne!(self.head, Some(ptr)); unsafe { T::pointers(ptr).as_mut().next = self.head; T::pointers(ptr).as_mut().prev = None; if let Some(head) = self.head { T::pointers(head).as_mu...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
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
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
T::pointers(node).as_mut().prev = None; Some(T::from_raw(node)) } } impl<T: Link> fmt::Debug for LinkedList<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("LinkedList") .field("head", &self.head) .field("tail", &self.tail) .fi...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
} } impl<'a, T: Link> Iterator for Iter<'a, T> { type Item = &'a T::Target; fn next(&mut self) -> Option<&'a T::Target> { let curr = self.curr?; // safety: the pointer references data contained by the list self.curr = unsafe { T::pointers(curr).as_ref() }.ne...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
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>; type Target = Entry; fn as_raw(handle: &Pin<&'_ Entry>) -> NonNull<En...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:8
let mut ret = vec![]; while let Some(entry) = list.pop_back() { ret.push(entry.val); } ret } fn push_all<'a>(list: &mut LinkedList<&'a Entry>, entries: &[Pin<&'a Entry>]) { for entry in entries.iter() { list.push_front(*entry); } } macr...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
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); assert!(list.is_empty()); } #[test] fn push_pop_push_pop() { let a = entry(5); let b = entry(7); let mu...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
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't be removed twice assert!(list.remove(ptr(&a)).is_none()); assert!(!list.is_empty()); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
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_eq!(c, a.pointers.next); assert_ptr_eq!(a, c.pointers.prev); let items = collect...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
// 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_ptr_eq!(b, list.tail); assert!(b.pointers.next.is_none()); assert!(b.pointers.prev.is_none()); let items = co...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
assert!(list.remove(ptr(&a)).is_some()); assert_clean!(a); assert!(list.head.is_none()); assert!(list.tail.is_none()); let items = collect_list(&mut list); assert!(items.is_empty()); } unsafe { // Remove missing let mu...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
481
540
tokio-rs/tokio:tokio/src/util/linked_list.rs:14
fn fuzz_linked_list(ops: Vec<usize>) { run_fuzz(ops); } } fn run_fuzz(ops: Vec<usize>) { use std::collections::VecDeque; #[derive(Debug)] enum Op { Push, Pop, Remove(usize), } let ops = ops .iter() ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
521
580
tokio-rs/tokio:tokio/src/util/linked_list.rs:15
assert!(ll.is_empty()); continue; } let v = reference.pop_back(); assert_eq!(v, ll.pop_back().map(|v| v.val)); } Op::Remove(n) => { if reference.is_empty() { a...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
00725f6876821f2ec5246a807563e35c5e53f3e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/util/linked_list.rs
561
585
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
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
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
T::pointers(node).as_mut().prev = None; Some(T::from_raw(node)) } } cfg_sync! { impl<T: Link> LinkedList<T> { /// Splits this list off at `node`, returning a new list with `node` at its /// front. /// /// If `node` is at the the front of this list, then this list will b...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
tail: self.tail.take(), } } } } impl<T: Link> fmt::Debug for LinkedList<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("LinkedList") .field("head", &self.head) .field("tail", &self.tail) .finish() } } // ===== ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
fn next(&mut self) -> Option<&'a T::Target> { let curr = self.curr?; // safety: the pointer references data contained by the list self.curr = unsafe { T::pointers(curr).as_ref() }.next; // safety: the value is still owned by the linked list. Some(unsafe { &*curr.as_ptr() }) ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:8
.field("prev", &self.prev) .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 Entr...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
}) } fn ptr(r: &Pin<Box<Entry>>) -> NonNull<Entry> { r.as_ref().get_ref().into() } fn collect_list(list: &mut LinkedList<&'_ Entry>) -> Vec<i32> { let mut ret = vec![]; while let Some(entry) = list.pop_back() { ret.push(entry.val); } ret } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
let b = entry(7); let c = entry(31); 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 li...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
fn remove_by_address() { let a = entry(5); let b = entry(7); 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())...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
assert_ptr_eq!(b, c.pointers.prev); let items = collect_list(&mut list); 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()]); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
// Remove first of two let mut list = LinkedList::new(); 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(pt...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
481
540
tokio-rs/tokio:tokio/src/util/linked_list.rs:14
} unsafe { // 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()); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
521
580
tokio-rs/tokio:tokio/src/util/linked_list.rs:15
let mut i = list.iter(); assert_eq!(7, i.next().unwrap().val); assert_eq!(5, i.next().unwrap().val); assert!(i.next().is_none()); } #[test] fn split_back() { let a = entry(1); let b = entry(2); let c = entry(3); let d = entry(4); { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
561
620
tokio-rs/tokio:tokio/src/util/linked_list.rs:16
let mut list1 = LinkedList::<&Entry>::new(); push_all( &mut list1, &[a.as_ref(), b.as_ref(), c.as_ref(), d.as_ref()], ); let mut list2 = unsafe { list1.split_back(ptr(&c)) }; assert_eq!([4].to_vec(), collect_list(&mut list1)); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
601
660
tokio-rs/tokio:tokio/src/util/linked_list.rs:17
assert!(!list2.is_empty()); assert_eq!(Vec::<i32>::new(), collect_list(&mut list1)); assert_eq!([1, 2].to_vec(), collect_list(&mut list2)); } proptest::proptest! { #[test] fn fuzz_linked_list(ops: Vec<usize>) { run_fuzz(ops); } } fn run_fuzz(ops: Ve...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
641
700
tokio-rs/tokio:tokio/src/util/linked_list.rs:18
Op::Push => { reference.push_front(i as i32); assert_eq!(entries[i].val, i as i32); ll.push_front(entries[i].as_ref()); } Op::Pop => { if reference.is_empty() { assert!(ll.is_empty())...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
acf8a7da7a64bf08d578db9a9836a8e061765314
github
async-runtime
https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/util/linked_list.rs
681
713
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::mem::ManuallyDrop; use core::ptr::NonNull; /// An intrusive...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
1
60
tokio-rs/tokio:tokio/src/util/linked_list.rs:2
/// 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 unsafe fn from_raw(ptr: NonNull<Self::Target>) -> Self::Handle; /// Return the pointers for a node...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
41
100
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
// The value should not be dropped, it is being inserted into the list let val = ManuallyDrop::new(val); let ptr = T::as_raw(&*val); unsafe { T::pointers(ptr).as_mut().next = self.head; T::pointers(ptr).as_mut().prev = None; if let Some(head) = self.head { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
/// 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()); true } /// Removes the specified node from the list /// /// # Safety /// ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
T::pointers(node).as_mut().next = None; T::pointers(node).as_mut().prev = None; Some(T::from_raw(node)) } } // ===== impl Iter ===== cfg_rt_threaded! { use core::marker::PhantomData; pub(crate) struct Iter<'a, T: Link> { curr: Option<NonNull<T::Target>>, _p: PhantomData<&...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
// ===== impl Pointers ===== impl<T> Pointers<T> { /// Create a new set of empty pointers pub(crate) fn new() -> Pointers<T> { Pointers { prev: None, next: None, } } } #[cfg(test)] #[cfg(not(loom))] mod tests { use super::*; use std::pin::Pin; struct E...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
fn entry(val: i32) -> Pin<Box<Entry>> { 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>) -> Vec<i32> { let mut re...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:8
} #[test] fn push_and_drain() { let a = entry(5); let b = entry(7); let c = entry(31); 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....
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
assert!(list.is_empty()); assert!(list.pop_back().is_none()); } #[test] fn remove_by_address() { let a = entry(5); let b = entry(7); let c = entry(31); unsafe { // Remove first let mut list = LinkedList::new(); push_all(&mut list...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
assert!(list.remove(ptr(&a)).is_some()); assert_clean!(a); assert_ptr_eq!(b, list.head); assert_ptr_eq!(c, b.pointers.next); assert_ptr_eq!(b, c.pointers.prev); let items = collect_list(&mut list); assert_eq!([31, 7].to_vec(), items); } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
let items = collect_list(&mut list); assert_eq!([7, 5].to_vec(), items); } unsafe { // Remove first of two let mut list = LinkedList::new(); push_all(&mut list, &[b.as_ref(), a.as_ref()]); assert!(list.remove(ptr(&a)).is_some()); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
assert!(a.pointers.next.is_none()); assert!(a.pointers.prev.is_none()); let items = collect_list(&mut list); assert_eq!([5].to_vec(), items); } unsafe { // Remove last item let mut list = LinkedList::new(); push_all(&mut list, &[...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
assert_eq!(0, list.iter().count()); list.push_front(a.as_ref()); list.push_front(b.as_ref()); let mut i = list.iter(); assert_eq!(7, i.next().unwrap().val); assert_eq!(5, i.next().unwrap().val); assert!(i.next().is_none()); } proptest::proptest! { #[tes...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/util/linked_list.rs
481
540
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::ptr::NonNull; /// An intrusive linked list. /// /// Current...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
1
60
tokio-rs/tokio:tokio/src/util/linked_list.rs:2
/// Node type type Target; /// Convert the handle to a raw pointer /// /// Consumes ownership of the handle. fn to_raw(handle: Self::Handle) -> NonNull<Self::Target>; /// Convert the raw pointer to a handle unsafe fn from_raw(ptr: NonNull<Self::Target>) -> Self::Handle; /// Return the...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
41
100
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
pub(crate) fn push_front(&mut self, val: T::Handle) { let ptr = T::to_raw(val); unsafe { T::pointers(ptr).as_mut().next = self.head; T::pointers(ptr).as_mut().prev = None; if let Some(head) = self.head { T::pointers(head).as_mut().prev = Some(ptr); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
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
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
T::pointers(node).as_mut().prev = None; true } } // ===== impl Pointers ===== impl<T> Pointers<T> { /// Create a new set of empty pointers pub(crate) fn new() -> Pointers<T> { Pointers { prev: None, next: None, } } } #[cfg(test)] #[cfg(not(loom))] mod ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
} 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
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
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 push_and_drain() { let a = entry(5); let b = entry(7); let c = e...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:8
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 = entry(5); let b = entry(7); let c = entry(31); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
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))); assert_clean!(a); assert_ptr_eq!(b, list.head); assert_ptr_eq!(c, b.pointers.next)...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
assert!(list.remove(ptr(&c))); assert_clean!(c); assert!(b.pointers.next.is_none()); assert_ptr_eq!(b, list.tail); let items = collect_list(&mut list); assert_eq!([7, 5].to_vec(), items); } unsafe { // Remove first of two ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
assert_clean!(b); assert_ptr_eq!(a, list.head); assert_ptr_eq!(a, list.tail); assert!(a.pointers.next.is_none()); assert!(a.pointers.prev.is_none()); let items = collect_list(&mut list); assert_eq!([5].to_vec(), items); } unsafe...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
#[test] fn fuzz_linked_list(ops: Vec<usize>) { run_fuzz(ops); } } fn run_fuzz(ops: Vec<usize>) { use std::collections::VecDeque; #[derive(Debug)] enum Op { Push, Pop, Remove(usize), } let ops = ops ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
441
500
tokio-rs/tokio:tokio/src/util/linked_list.rs:13
if reference.is_empty() { assert!(ll.is_empty()); continue; } let v = reference.pop_back(); assert_eq!(v, ll.pop_back().map(|v| v.val)); } Op::Remove(n) => { i...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/util/linked_list.rs
481
505
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::cell::UnsafeCell; use core::marker::PhantomPinned; use core:...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
1
60
tokio-rs/tokio:tokio/src/util/linked_list.rs:2
unsafe impl<T: Sync> Sync for Entry<T> {} impl<T> LinkedList<T> { /// Creates an empty linked list pub(crate) fn new() -> Self { LinkedList { head: None, tail: None, } } /// Adds an item to the back of the linked list. /// /// # Safety /// /// Th...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
41
100
tokio-rs/tokio:tokio/src/util/linked_list.rs:3
let mut last = self.tail?; self.tail = last.as_ref().prev; if let Some(mut prev) = last.as_mut().prev { prev.as_mut().next = None; } else { self.head = None } last.as_mut().prev = None; last.as_mut().next = None; ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
81
140
tokio-rs/tokio:tokio/src/util/linked_list.rs:4
} else { if self.head != Some(entry) { return false; } self.head = entry.as_ref().next; } if let Some(mut next) = entry.as_mut().next { debug_assert_eq!(next.as_ref().prev, Some(entry)); next.as_mut().prev = entry.as_ref().pre...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
121
180
tokio-rs/tokio:tokio/src/util/linked_list.rs:5
self.data.get() } } #[cfg(test)] #[cfg(not(loom))] mod tests { use super::*; fn collect_list<T: Copy>(list: &mut LinkedList<T>) -> Vec<T> { let mut ret = vec![]; while let Some(v) = list.pop_back() { ret.push(*v); } ret } unsafe fn push_all(list: &mut...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
161
220
tokio-rs/tokio:tokio/src/util/linked_list.rs:6
fn push_and_drain() { pin! { let a = Entry::new(5); let b = Entry::new(7); let c = Entry::new(31); } let mut list = LinkedList::new(); assert!(list.is_empty()); unsafe { list.push_front(a); assert!(!list.is_empty()); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
201
260
tokio-rs/tokio:tokio/src/util/linked_list.rs:7
unsafe { list.push_front(b); } let v = list.pop_back().unwrap(); assert_eq!(7, *v); assert!(list.is_empty()); assert!(list.pop_back().is_none()); } #[test] fn remove_by_address() { pin! { let a = Entry::new(5); let b = En...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
241
300
tokio-rs/tokio:tokio/src/util/linked_list.rs:8
assert!(list.is_empty()); } unsafe { // Remove middle let mut list = LinkedList::new(); push_all(&mut list, &mut [c.as_mut(), b.as_mut(), a.as_mut()]); assert!(list.remove(a.as_mut())); assert_clean!(a); assert_ptr_eq!(b, list.h...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
281
340
tokio-rs/tokio:tokio/src/util/linked_list.rs:9
push_all(&mut list, &mut [c.as_mut(), b.as_mut(), a.as_mut()]); assert!(list.remove(c.as_mut())); assert_clean!(c); assert!(b.next.is_none()); assert_ptr_eq!(b, list.tail); let items = collect_list(&mut list); assert_eq!([7, 5].to_vec(), items);...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
321
380
tokio-rs/tokio:tokio/src/util/linked_list.rs:10
push_all(&mut list, &mut [b.as_mut(), a.as_mut()]); assert!(list.remove(b.as_mut())); assert_clean!(b); assert_ptr_eq!(a, list.head); assert_ptr_eq!(a, list.tail); assert!(a.next.is_none()); assert!(a.prev.is_none()); let items = c...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
361
420
tokio-rs/tokio:tokio/src/util/linked_list.rs:11
} proptest::proptest! { #[test] fn fuzz_linked_list(ops: Vec<usize>) { run_fuzz(ops); } } fn run_fuzz(ops: Vec<usize>) { use std::collections::VecDeque; #[derive(Debug)] enum Op { Push, Pop, Remove(usize), ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
401
460
tokio-rs/tokio:tokio/src/util/linked_list.rs:12
reference.push_front(v); entries.push_front(Box::pin(Entry::new(v))); unsafe { ll.push_front(entries.front_mut().unwrap().as_mut()); } } Op::Pop => { if reference.is_empty() { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/util/linked_list.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/util/linked_list.rs
441
478
tokio-rs/tokio:tokio/src/util/markers.rs:1
/// Marker for types that are `Sync` but not `Send` #[allow(dead_code)] pub(crate) struct SyncNotSend(#[allow(dead_code)] *mut ()); unsafe impl Sync for SyncNotSend {} cfg_rt! { pub(crate) struct NotSendOrSync(#[allow(dead_code)] *mut ()); }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/markers.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/markers.rs
1
9
tokio-rs/tokio:tokio/src/util/markers.rs:1
/// Marker for types that are `Sync` but not `Send` pub(crate) struct SyncNotSend(#[allow(dead_code)] *mut ()); unsafe impl Sync for SyncNotSend {} cfg_rt! { pub(crate) struct NotSendOrSync(#[allow(dead_code)] *mut ()); }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/markers.rs
MIT
bb25a06f348c8069308e6145623dd3743d87564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bb25a06f348c8069308e6145623dd3743d87564d/tokio/src/util/markers.rs
1
8
tokio-rs/tokio:tokio/src/util/markers.rs:1
/// Marker for types that are `Sync` but not `Send` pub(crate) struct SyncNotSend(*mut ()); unsafe impl Sync for SyncNotSend {} cfg_rt! { pub(crate) struct NotSendOrSync(*mut ()); }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/markers.rs
MIT
1204da730000f2eab19d2c05eea12ee3071b3f31
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1204da730000f2eab19d2c05eea12ee3071b3f31/tokio/src/util/markers.rs
1
8
tokio-rs/tokio:tokio/src/util/memchr.rs:1
//! Search for a byte in a byte array using libc. //! //! When nothing pulls in libc, then just use a trivial implementation. Note //! that we only depend on libc on unix. #[cfg(not(all(unix, feature = "libc")))] fn memchr_inner(needle: u8, haystack: &[u8]) -> Option<usize> { haystack.iter().position(|val| needle ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/memchr.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/memchr.rs
1
60
tokio-rs/tokio:tokio/src/util/memchr.rs:2
// therefore the index must **always** point to an element in the array // and so this indexing operation is safe // TODO(MSRV 1.81): When bumping MSRV, switch to `std::hint::assert_unchecked(haystack.get(..=index).is_some());` unsafe { if haystack.get(..=index).is_none() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/memchr.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/memchr.rs
41
100
tokio-rs/tokio:tokio/src/util/memchr.rs:3
#[test] fn memchr_all() { let mut arr = Vec::new(); for b in 0..=255 { arr.push(b); } for b in 0..=255 { assert_eq!(memchr(b, &arr), Some(b as usize)); } arr.reverse(); for b in 0..=255 { assert_eq!(memchr(b, &arr), Some(255...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/memchr.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/memchr.rs
81
102
tokio-rs/tokio:tokio/src/util/memchr.rs:1
//! Search for a byte in a byte array using libc. //! //! When nothing pulls in libc, then just use a trivial implementation. Note //! that we only depend on libc on unix. #[cfg(not(all(unix, feature = "libc")))] fn memchr_inner(needle: u8, haystack: &[u8]) -> Option<usize> { haystack.iter().position(|val| needle ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/memchr.rs
MIT
67682ac2e87e27b4791e33467a7c6e773e0c2179
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67682ac2e87e27b4791e33467a7c6e773e0c2179/tokio/src/util/memchr.rs
1
60
tokio-rs/tokio:tokio/src/util/memchr.rs:2
// therfore the index must **always** point to an element in the array // and so this indexing operation is safe // TODO(MSRV 1.81): When bumping MSRV, switch to `std::hint::assert_unchecked(haystack.get(..=index).is_some());` unsafe { if haystack.get(..=index).is_none() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/memchr.rs
MIT
67682ac2e87e27b4791e33467a7c6e773e0c2179
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67682ac2e87e27b4791e33467a7c6e773e0c2179/tokio/src/util/memchr.rs
41
100
tokio-rs/tokio:tokio/src/util/memchr.rs:1
//! Search for a byte in a byte array using libc. //! //! When nothing pulls in libc, then just use a trivial implementation. Note //! that we only depend on libc on unix. #[cfg(not(all(unix, feature = "libc")))] pub(crate) fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> { haystack.iter().position(|val| ne...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/memchr.rs
MIT
bfa9ea8d9b4cee3d3b7a9222ae4987cbd6c7d6b2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bfa9ea8d9b4cee3d3b7a9222ae4987cbd6c7d6b2/tokio/src/util/memchr.rs
1
60
tokio-rs/tokio:tokio/src/util/memchr.rs:2
assert_eq!(memchr(b'b', haystack), Some(4)); assert_eq!(memchr(b'c', haystack), Some(5)); assert_eq!(memchr(b'd', haystack), None); assert_eq!(memchr(b'A', haystack), None); assert_eq!(memchr(0, haystack), Some(9)); assert_eq!(memchr(0xff, haystack), Some(10)); assert_eq!...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/memchr.rs
MIT
bfa9ea8d9b4cee3d3b7a9222ae4987cbd6c7d6b2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bfa9ea8d9b4cee3d3b7a9222ae4987cbd6c7d6b2/tokio/src/util/memchr.rs
41
74
tokio-rs/tokio:tokio/src/util/metric_atomics.rs:1
use std::sync::atomic::{AtomicUsize, Ordering}; cfg_64bit_metrics! { use std::sync::atomic::AtomicU64; } /// `AtomicU64` that is a no-op on platforms without 64-bit atomics /// /// When used on platforms without 64-bit atomics, writes to this are no-ops. /// The `load` method is only defined when 64-bit atomics a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/metric_atomics.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/metric_atomics.rs
1
60
tokio-rs/tokio:tokio/src/util/metric_atomics.rs:2
cfg_no_64bit_metrics! { pub(crate) fn store(&self, _val: u64, _ordering: Ordering) { } // on platforms without 64-bit atomics, fetch-add returns unit pub(crate) fn add(&self, _value: u64, _ordering: Ordering) { } pub(crate) fn new(_value: u64) -> Self { Self { } } } } #[cfg_attr(no...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/metric_atomics.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/metric_atomics.rs
41
81
tokio-rs/tokio:tokio/src/util/metric_atomics.rs:1
use std::sync::atomic::{AtomicUsize, Ordering}; cfg_64bit_metrics! { use std::sync::atomic::AtomicU64; } /// `AtomicU64` that is is a no-op on platforms without 64-bit atomics /// /// When used on platforms without 64-bit atomics, writes to this are no-ops. /// The `load` method is only defined when 64-bit atomic...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/metric_atomics.rs
MIT
9a75d6f7f70fd81f589a8209c548944bc3d05f84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a75d6f7f70fd81f589a8209c548944bc3d05f84/tokio/src/util/metric_atomics.rs
1
60
tokio-rs/tokio:tokio/src/util/metric_atomics.rs:1
use std::sync::atomic::Ordering; cfg_64bit_metrics! { use std::sync::atomic::AtomicU64; } /// `AtomicU64` that is is a no-op on platforms without 64-bit atomics /// /// When used on platforms without 64-bit atomics, writes to this are no-ops. /// The `load` method is only defined when 64-bit atomics are available...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/metric_atomics.rs
MIT
8e15c234c60cf8132c490ccf03dd31738cfeaca8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8e15c234c60cf8132c490ccf03dd31738cfeaca8/tokio/src/util/metric_atomics.rs
1
60