This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use core::{ | |
| mem::{self, MaybeUninit}, | |
| ptr, | |
| }; | |
| /// This struct is a simple wrapper around `[MaybeUninit<T>; N]`. | |
| /// It provides some convenience methods for working with arrays that may have uninitialized items. | |
| pub(crate) struct MaybeArray<T, const N: usize> { | |
| array: [MaybeUninit<T>; N] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![no_std] | |
| #[inline] | |
| pub const unsafe fn fake_type<T>() -> T { | |
| hint_unreachable() | |
| } | |
| #[inline] | |
| pub const unsafe fn hint_unreachable() -> ! { | |
| fake_type() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(const_generics)] | |
| struct Range { | |
| start: usize, | |
| end: usize, | |
| } | |
| impl Range { | |
| pub const fn new(start: usize, end: usize) -> Self { | |
| Self { start, end } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![allow(dead_code, unused_variables)] | |
| #![feature(const_generics)] | |
| pub type uinfo = u32; | |
| pub struct Debug<T, const LINE: uinfo, const COLUMN: uinfo> { | |
| pub inner: T, | |
| } | |
| impl <T, const LINE: uinfo, const COLUMN: uinfo> Debug<T, {LINE}, {COLUMN}> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::marker::PhantomData; | |
| use std::ops::{Deref, DerefMut}; | |
| /// Fake stdlib's TraitObject: | |
| /// https://doc.rust-lang.org/std/raw/struct.TraitObject.html | |
| /// That requires nightly, but this works on stable. | |
| #[derive(Copy, Clone)] | |
| #[repr(C)] | |
| struct TraitObject { | |
| _data: *mut (), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::{ | |
| ops::{Generator, GeneratorState}, | |
| pin::Pin, | |
| }; | |
| /// A wrapper struct around Generators, | |
| /// providing a safe implementation of the [`Iterator`] trait. | |
| pub struct GenIter<G>(Option<G>); | |
| impl<G: Generator + Unpin> GenIter<G> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(nll)] | |
| use std::marker::PhantomData; | |
| // Can't make it longer or shorter | |
| #[derive(Copy, Clone)] | |
| struct Invariant<'id>(PhantomData<*mut &'id ()>); | |
| impl<'id> Invariant<'id> { | |
| pub const fn new() -> Self { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use crate::{ | |
| container::container::{Container, scope}, | |
| fundemental::{range::Range, proof::NonEmpty, index::Index}, | |
| }; | |
| pub fn qsort<T: Ord>(slice: &mut [T]) { | |
| scope(slice, |mut v| { | |
| if let Ok(range) = v.range().nonempty() { | |
| quicksort(&mut v, range); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::cell::RefCell; | |
| trait Defer { | |
| fn call(self: Box<Self>); | |
| } | |
| impl<F: FnOnce(T), T> Defer for (F, T) { | |
| fn call(self: Box<Self>) { | |
| (self.0)(self.1); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(exact_chunks)] | |
| const POW10_U64: [u64; 20] = [ | |
| 10_000_000_000_000_000_000, | |
| 1_000_000_000_000_000_000, | |
| 100_000_000_000_000_000, | |
| 10_000_000_000_000_000, | |
| 1_000_000_000_000_000, | |
| 100_000_000_000_000, | |
| 10_000_000_000_000, |