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] | |
| // Conditionally link `std` when compiling an executable target (non-test binary) | |
| #[cfg(not(test))] | |
| extern crate std; | |
| /// A lightweight, fast, `#![no_std]` Pseudo-Random Number Generator (PRNG) | |
| /// based on the Xoroshiro128++ algorithm. | |
| #[derive(Debug, Clone, PartialEq, Eq)] | |
| pub struct Xoroshiro128PlusPlus { |
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(unused_imports)] | |
| use sha2::{Digest, Sha256}; | |
| #[allow(unused_imports)] | |
| use std::time::Instant; | |
| // ============================================================================ | |
| // Cross-Platform Hardware CPU Tick Counter | |
| // ============================================================================ | |
| /// Reads the low-level CPU tick counter across x86/x86_64, AArch64, and RISC-V. |
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
| /// Solves the 0/1 Knapsack problem using Dynamic Programming. | |
| /// | |
| /// # Arguments | |
| /// * `max_weight` - The maximum weight capacity of the knapsack. | |
| /// * `weights` - A slice containing the weights of the available items. | |
| /// * `values` - A slice containing the values of the available items. | |
| /// | |
| /// # Returns | |
| /// The maximum value that can be accommodated within the given capacity. | |
| pub fn knapsack(max_weight: usize, weights: &[usize], values: &[usize]) -> usize { |
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::time::{SystemTime, UNIX_EPOCH}; | |
| /// Simple Xorshift PRNG to maintain a 0-dependency standard library build. | |
| struct Prng { | |
| state: u32, | |
| } | |
| impl Prng { | |
| fn new() -> Self { | |
| let nanos = SystemTime::now() |
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
| // ========================================== | |
| // INCORRECT: Dyn-Incompatible Trait | |
| // ========================================== | |
| // Uncommenting this will cause a compilation error: | |
| // "the trait `Processor` cannot be made into an object" | |
| /* | |
| trait Processor { | |
| // Error 1: Uses `Self` in return position | |
| fn duplicate(&self) -> 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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| INSTALL_DIR="/usr/local/bin" | |
| SCRIPT_NAME="git-clone-gists" | |
| CLONE_DIR="${CLONE_DIR:-gists}" | |
| show_usage() { | |
| cat <<EOF | |
| Usage: $0 [install|uninstall|--help] [--force] [--user USERNAME] [filters] [github-token] |
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(deprecated)] | |
| //#![feature(cfg_select, assert_matches)] | |
| use std::assert_matches; | |
| use rand_0_8_6::{thread_rng as rng_legacy, Rng as RngLegacy}; | |
| use rand_0_9_4::{thread_rng as rng_latest, Rng as RngLatest}; | |
| use num_bigint::BigUint; | |
| use chrono::Local; |
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
| //// Coltrane's Circle of Tones | |
| // Written using only the Rust Standard Library. | |
| use std::fmt; | |
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | |
| enum Note { | |
| C, Db, D, Eb, E, F, Gb, G, Ab, A, Bb, B, | |
| } |
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
| Cargo.lock |
NewerOlder