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
| /// This piece of code is used whenever the number of iterations is comptime known. | |
| /// `n` == iterations. | |
| for ([_]u8{0} ** n) |_, i| { | |
| } | |
| /// This piece of code is used whenever the number of iterations is runtime known. | |
| //// `n` == iterations. | |
| for (@as([*]u0, undefined)[0..n]) |_, i| { | |
| } |
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] | |
| //#![no_implicit_prelude] | |
| #[cfg(feature = "alloc")] | |
| extern crate alloc; | |
| #[cfg(feature = "std")] | |
| extern crate std; |
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
| #[inline(always)] | |
| #[track_caller] | |
| const unsafe fn unreachable() -> ! { | |
| #[derive(Copy, Clone)] | |
| enum Void {} | |
| const NEVER: *const Void = [].as_ptr(); | |
| match *NEVER {} | |
| } |
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
| const Builder = @import("std").build.Builder; | |
| const std = @import("std"); | |
| const cpu = @import("std").Target.arm; | |
| pub fn build(b: *Builder) void { | |
| const mode = b.standardReleaseOptions(); | |
| const lib = b.addStaticLibrary("krate", "src/main.zig"); | |
| lib.setBuildMode(mode); | |
| lib.target = std.zig.CrossTarget{ | |
| .cpu_arch = .thumb, | |
| .os_tag = .freestanding, |
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(untagged_unions)] | |
| #![feature(const_generics, const_evaluatable_checked)] | |
| #![allow(incomplete_features)] | |
| use core::mem::ManuallyDrop; | |
| struct Bool<const B: bool>; | |
| trait 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
| use { | |
| crate as this, | |
| this as me, | |
| me::self as i | |
| }; |
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
| const std = @import("std"); | |
| const testing = std.testing; | |
| const meta = std.meta; | |
| pub const Type = union(enum) { | |
| Character, | |
| Number, | |
| String, | |
| }; |
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
| const std = @import("std"); | |
| const testing = std.testing; | |
| const meta = std.meta; | |
| pub const Type = union(enum) { | |
| Character, | |
| }; | |
| pub const Ammount = union(enum) { | |
| Infinite, |
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::slice; | |
| pub fn chunks_exact<T>(slice: &[T], chunk_size: usize) -> ChunksExact<'_, T> { | |
| assert!(chunk_size != 0); | |
| let rem = slice.len() % chunk_size; | |
| let len = slice.len() - rem; | |
| let (fst, snd) = slice.split_at(len); | |
| let len = fst.len(); |
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_trait_bound_opt_out)] | |
| #![feature(const_fn)] | |
| #![feature(const_trait_impl)] | |
| #![feature(const_if_match)] | |
| #![feature(const_loop)] | |
| #![feature(const_mut_refs)] | |
| trait CollatzTransform: Sized { | |
| fn transform(self) -> Option<Self>; | |
| } |