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
| pub fn load_in_place<'a, T>(bytes: &'a [u8]) -> &'a T { | |
| assert!(!bytes.is_empty()); | |
| assert!(validate::<T>(bytes)); | |
| unsafe { &*bytes.as_ptr().cast() } | |
| } | |
| #[cfg(test)] |
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, | |
| ops::Deref, | |
| ptr::NonNull, | |
| sync::atomic::{AtomicI32, Ordering}, | |
| }; | |
| struct Inner<T: ?Sized> { | |
| // Number of strong references in addition to the current value. | |
| // A negative value indicates a non-atomic reference count, counting up from i32::MIN |
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
| /// Flexible Reference Kounting | |
| use std::{ | |
| marker::PhantomData, | |
| ops::Deref, | |
| ptr::NonNull, | |
| sync::atomic::{AtomicI32, Ordering}, | |
| }; | |
| struct Inner<T: ?Sized> { | |
| // Number of strong references in addition to the current value. |
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
| mod rc; | |
| use rc::{BoxArc, BoxRc}; | |
| struct Widget { | |
| value: i32, | |
| } | |
| impl Widget { | |
| fn new(value: i32) -> 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 std::{ | |
| ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}, | |
| time::{Duration, Instant}, | |
| }; | |
| use sdl2::{event::Event, rect::Rect, render::WindowCanvas, Sdl}; | |
| #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] | |
| pub struct Vec2 { | |
| pub x: i32, |
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 sdl2::{event::Event, keyboard::Keycode}; | |
| use slappy::{Colour, Draw, Input, Loop, TickState, Vec2}; | |
| #[derive(Default)] | |
| struct PongInput { | |
| player_1_up: bool, | |
| player_1_down: bool, | |
| player_2_up: bool, | |
| player_2_down: bool, | |
| } |
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::UnsafeCell; | |
| use std::sync::atomic::{spin_loop_hint, AtomicBool, AtomicU32, Ordering}; | |
| use std::sync::{Barrier, Mutex}; | |
| use std::ops::{Deref, DerefMut}; | |
| use std::thread; | |
| use parking_lot; | |
| struct LockInner(AtomicBool); | |
| const LOCKED: bool = true; |
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
| #include <elfutils/libdwfl.h> | |
| #define UNW_LOCAL_ONLY | |
| #include <libunwind.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <stdarg.h> | |
| #include <unistd.h> | |
| #include <errno.h> |
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::fs::File; | |
| use std::io::BufWriter; | |
| use std::io::Write as IoWrite; | |
| use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; | |
| use std::path::Path; | |
| use rand::{Rng, SeedableRng}; | |
| use rand_distr::{Distribution, UnitDisc, UnitSphere}; | |
| use rand_pcg; |
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
| let mapleader="," | |
| " Specify a directory for plugins | |
| " - For Neovim: ~/.local/share/nvim/plugged | |
| " - Avoid using standard Vim directory names like 'plugin' | |
| call plug#begin('~/.local/share/nvim/plugged') | |
| Plug 'godlygeek/tabular' | |
| Plug 'rust-lang/rust.vim' | |
| Plug 'ctrlpvim/ctrlp.vim' |
NewerOlder