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 std::time::Duration; | |
struct CachedValue<T, U> { | |
last : Duration, | |
value : T, | |
updateFunction : U, | |
} | |
impl <T, U> CachedValue<T,U> { |
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 = 100; | |
difference() { | |
cube([53, 72, 1.5], center=true); | |
cube([42, 60, 2.5], center=true); | |
translate([0, 0, 0.5]) | |
difference() { | |
cube([51.5,70.25,1.5], center=true); | |
translate([51.5/2-2.4, 70.25/2-2.9, 0]) cylinder(d=2.8,, h=10, center=true); | |
translate([51.5/2-2.4, -(70.25/2-2.9), 0]) cylinder(d=2.8, h=10, center=true); |
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 main() { | |
let addone = |n: u8| n + 1; | |
let mut n = 0; | |
// Test types | |
//() = addone | |
//() = addone_fn | |
// What must change for this to work? | |
//async_calc(&mut n, addone); |
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 main() { | |
let cmd = "python run.py args".to_string(); | |
let v: Vec<&str> = cmd.split(' ').collect(); | |
if v.len() > 0 { | |
println!("Command::new( {:?} )", v[0]); | |
for arg in v.split_at(1).1 { | |
println!(" .arg( {:?} )", arg); |
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 main() { | |
let nothing: Option<usize> = None; | |
if let None = nothing { | |
println!("None"); | |
} | |
} |
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 std::time::*; | |
#[allow(unused_variables)] | |
fn main() { | |
let now = SystemTime::now(); | |
let now = now.duration_since(UNIX_EPOCH).unwrap(); | |
let secs = now.as_secs(); | |
let mins = secs / 60; | |
let hours = secs / (60 * 60); |
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
#[derive(PartialEq)] | |
struct A { | |
a: u64, b: u64, c: u64, | |
} | |
impl A { | |
fn new() -> A { | |
A { | |
a: 64, b: 64, c: 64, | |
} |
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 std::collections::HashMap; | |
use std::sync::Arc; | |
use std::thread::{spawn, sleep}; | |
use std::time::{Duration, Instant}; | |
fn main() { | |
let now = Instant::now(); | |
let mut map = HashMap::new(); | |
map.insert("hi", "lo"); | |
map.insert("L", "R"); |
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
#[derive(Debug)] | |
enum E { | |
A, D(i64) | |
} | |
use E::*; | |
fn main() { | |
print(A); | |
print(D(2)); | |
print(D(32)); |
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
// Gist: https://gist.github.com/dns2utf8/525e4b1932d822088e40a9b1c2af9547 | |
#[allow(dead_code, unused_variables)] | |
fn f0(i: i32) { } | |
#[allow(dead_code, unused_variables)] | |
fn f1(i: i32) { } | |
#[allow(unused_assignments)] | |
fn main() { |
OlderNewer