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
extern crate proc_macro; | |
use quote::quote; | |
use proc_macro2::{TokenTree, TokenStream}; | |
#[proc_macro] | |
pub fn why(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream { | |
use quote::ToTokens; | |
let a = quote! { 1 + 2 }; | |
// delimit a to maintain correct precedence behaviour |
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 build | |
Compiling normal_macro v0.1.0 (C:\Users\Maurits\Projects\macro_bug\normal_macro) | |
error[E0425]: cannot find value `a` in this scope | |
--> src\main.rs:5:43 | |
| | |
5 | ($test:expr) => {proc_macro::forward!($test)} | |
| ^^^^^ not found in this scope | |
... | |
12 | println!("{}", forward!(a)); | |
| ----------- in this macro invocation |
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 float EPSILON = 0.01; | |
const float MAX_DISTANCE = 100.; | |
const float SCREEN_DISTANCE = 2.; | |
const int MAX_ITER = 100; | |
// why o why does webGL not support inverse(mat3); | |
mat3 inv(mat3 m) { | |
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; | |
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2]; | |
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2]; |
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
; excerpt from loop_notrash as it got inlined in here | |
loc_140001050: | |
xor esi, esi | |
xor eax, eax | |
loc_140001054: | |
mov rcx, rax | |
lea rax, [rcx+rsi*2-2] | |
mov rdx, rsi | |
nop |
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 bench | |
Finished release [optimized] target(s) in 0.0 secs | |
Running target\release\deps\benching-22b624a5099107eb.exe | |
running 2 tests | |
test tests::loop_notrash ... bench: 1,053,106 ns/iter (+/- 162,958) | |
test tests::loop_trash ... bench: 1,458,335 ns/iter (+/- 149,239) | |
test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured |