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::BTreeMap as HashMap;//HashMap; | |
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] | |
enum Good { | |
Log, // Units: Kg | |
Wood, // Units Kg | |
Meat, // Units: Kg | |
Food, | |
} |
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::BTreeMap as HashMap;//HashMap; | |
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] | |
enum Good { | |
Log, // Units: Kg | |
Wood, // Units Kg | |
Fish, // Units: Kg | |
Food, | |
} |
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 Token { | |
Num(i64), | |
Paren(Vec<Token>), | |
Block(Vec<Token>), | |
} | |
fn lex(src: &str) -> Result<Vec<Token>, String> { | |
let mut ident_depth = 0; | |
let mut token_stack = vec![(ident_depth, Vec::new())]; |
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 ptr_at(pos: Vec2<isize>) -> *mut Px { ... } | |
type Px = u16; | |
pub unsafe fn line(&mut self, a: Vec2<isize>, b: Vec2<isize>, px: Px) { | |
let delta = b - a; | |
let delta_abs = delta.map(|e| e.abs() as usize); | |
let ptr = ptr_at(a.map(|e| e as usize)); | |
let dx = if delta.x > 0 { 1 } else { -1 }; | |
let dy = if delta.y > 0 { 1 } else { -1 } * WIDTH; |
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 super::*; | |
/// Synchronously block until a future completes. | |
/// | |
/// # Safety | |
/// | |
/// No waker provided to the future should ever be polled after the future returns `Poll::Ready`. The waker references | |
/// data on the blocking thread's stack and, as such, access to it after this point is UB because the data is no longer | |
/// a valid pointer. | |
#[allow(unused_unsafe)] // It's a stupid warning anyway. No such thing as unsafe code that's too explicit. |
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 s = r#"fn main() { | |
let s = @; | |
let x = s.find('@').unwrap(); | |
println!("{}r#\"{}\"{}{}", &s[..x], s, '#', &s[x + 1..]); | |
}"#; | |
let x = s.find('@').unwrap(); | |
println!("{}r#\"{}\"{}{}", &s[..x], s, '#', &s[x + 1..]); | |
} |
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 gui::{ | |
widget::{Toggle, Button, Label, List}, | |
layout::Direction, | |
event::Click, | |
Window, Widget, | |
}; | |
fn main() { | |
enum Op { | |
Add, |
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
diff --git a/assets/voxygen/shaders/figure-frag.glsl b/assets/voxygen/shaders/figure-frag.glsl | |
index 315807549..d5bea01a3 100644 | |
--- a/assets/voxygen/shaders/figure-frag.glsl | |
+++ b/assets/voxygen/shaders/figure-frag.glsl | |
@@ -146,7 +146,7 @@ void main() { | |
// DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos); | |
float point_shadow = shadow_at(f_pos, f_norm); | |
- DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos); | |
+ DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos, view_dir); |
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
#version 330 core | |
#include <globals.glsl> | |
#include <srgb.glsl> | |
#include <random.glsl> | |
in vec3 v_pos; | |
in uint v_col; | |
in uint v_norm_ao; | |
in vec3 inst_pos; |
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
# General utility | |
type Str = [Char] | |
type Io A = Universe -> (A, Universe) | |
fn nothing |uni of Universe| ((), uni) | |
fn print |s, uni| ((), @print(s, uni)) | |
fn input |uni| @input(uni) | |
data Maybe A = |