This file contains 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 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 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
fn helper<'a, 'b, T: ?Sized>(_: &'a &'b (), v: &'b T) -> &'a T { v } | |
fn helper_mut<'a, 'b, T: ?Sized>(_: &'a &'b (), v: &'b mut T) -> &'a mut T { v } | |
/// Use black magic fuckery to turn any `&T` into a `&'static T`. | |
/// May introduce undefined behavior. | |
pub fn make_static<'a, T: ?Sized>(input: &'a T) -> &'static T { | |
let f: fn(_, &'a T) -> &'static T = helper; | |
f(&&(), input) | |
} |
This file contains 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
pub(crate) struct MaybeArray<T, const N: usize> { | |
array: [MaybeUninit<T>; N], | |
} | |
impl<T, const N: usize> Default for MaybeArray<T, { N }> { | |
#[inline(always)] | |
fn default() -> Self { | |
Self { | |
array: unsafe { MaybeUninit::<_>::uninit().assume_init() }, | |
} |
This file contains 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(async_await)] | |
extern crate structopt; | |
use structopt::StructOpt; | |
use std::{ | |
future::Future as StdFuture, | |
net::{IpAddr, SocketAddr}, | |
}; |
This file contains 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
pub inline fn MaybeUninit(comptime T: type) type { | |
return packed union { | |
value: T, | |
uninit: void, | |
const Self = @This(); | |
inline fn init(value: T) Self { | |
return Self { .value = value }; | |
} |
This file contains 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
struct __<'__, ___: '__ = &'__ [()]> { | |
__: &'__ [__<'__, &'__ [___]>], | |
___: ___, | |
} | |
fn main() { | |
'__: while break '__ | |
== (|___: __<()>| -> () { ___.___ })(__::<()> { | |
__: &[][..], | |
___: (), |
This file contains 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] | |
/// Fakes a value of type `T`. | |
#[inline] | |
pub const unsafe fn fake_type<T>() -> T { | |
cold(); | |
unreachable() | |
} | |
/// Tells the compiler this code is unreachable. |
This file contains 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
MIT License | |
Copyright (c) 2021 DutchGhost | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR |
This file contains 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_mut_refs)] | |
#![feature(const_fn)] | |
#![feature(const_if_match)] | |
#![feature(const_loop)] | |
#![feature(const_raw_ptr_deref)] | |
#![feature(const_fn_union)] | |
#![feature(const_raw_ptr_to_usize_cast)] | |
#![feature(const_saturating_int_methods)] | |
use std::marker::PhantomData; |