-
Add Rustdoc root to the crate root
#![doc(html_root_url = "https://docs.rs/<crate>/<version>")]
(where
<crate>
is the crate name and<version>
is the version name)
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
#[derive(Eq, PartialEq, Debug, Copy, Clone)] | |
pub struct U256([u8; 32]); | |
impl Into<u8> for U256 { | |
fn into(self) -> u8 { | |
for b in &self.0[0..31] { | |
assert_eq!(*b, 0); | |
} | |
self.0[31] | |
} |
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/python3 | |
# Bart Massey | |
# Prime Christmas Tree printer, inspired by | |
# https://www.reddit.com/r/interestingasfuck/ | |
# comments/efhy5m/i_found_this_really_great_the_correct_alignment/ | |
# This code is licensed under the "MIT license". See | |
# https://opensource.org/licenses/MIT for license terms. |
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
// https://www.reddit.com/r/rust/comments/df12bs/roast_my_code_greatappender_repeatedly_append/ | |
use std::convert::TryInto; | |
use std::fs::OpenOptions; | |
use std::io::Write; | |
use std::sync::atomic::{AtomicBool, Ordering}; | |
use std::sync::Arc; | |
/// good-appender | |
fn main() { |
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::fmt::{self, Display, Formatter}; | |
use std::io::{self, Write}; | |
use tabwriter::TabWriter; | |
struct Table([[usize; 2]; 2]); | |
impl Display for Table { | |
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | |
let write_table = || -> io::Result<Vec<u8>> { |
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 serde::{Deserialize, Serialize}; | |
use std::collections::HashMap; | |
use std::io::Read; | |
#[derive(Serialize, Deserialize)] | |
#[serde(rename_all="camelCase")] | |
struct Item { | |
transfer_status : u64, | |
dismantle_permission : u64, |
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
// Copyright © 2019 Jeff Austin, Kamakshi Nagar | |
// [This program is licensed under the "MIT License"] | |
// Please see the file LICENSE in the source | |
// distribution of this software for license terms. | |
/* | |
citations: | |
Mark Morrissey --CS333 Operating Systems--Portland State University practice exams: | |
https://web.cecs.pdx.edu/~markem/CS333/exams/Final%202019-01.pdf |
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
#![deny(unused)] | |
use std::io::{self, Read}; | |
#[derive(PartialEq, Copy, Clone)] | |
enum Tile { | |
None, | |
Wall, | |
Goal, | |
} |
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 strict"; | |
class Some { | |
constructor(value) { | |
this.value = value; | |
} | |
is_some(self) { | |
return 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
a = 'a' | |
def f1(): | |
global a | |
a = 'af1' | |
f1() | |
# prints af1 | |
print(a) |