Skip to content

Instantly share code, notes, and snippets.

View FreeMasen's full-sized avatar

Robert Masen FreeMasen

View GitHub Profile
error[E0433]: failed to resolve. Use of undeclared type or module `wasm_bindgen`
--> crates\shared\src\models.rs:19:1
|
19 | #[wasm_bindgen]
| ^^^^^^^^^^^^^^^ Use of undeclared type or module `wasm_bindgen`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.
error: Could not compile `wasm_tutorial_shared`.
let cached_wasm;
function getWasm(): Promise<WebAssembly.Instance> {
return new Promise((resolve: (obj: WebAssembly.Instance) => void, reject: (e: Error) => void) => {
if (!cached_wasm) {
WebAssembly
.instantiateStreaming(fetch('rust.wasm'), {})
.then(obj => {
let cached_wasm = obj.instance.exports;
resolve(cached_wasm);
/* tslint:disable */
import * as wasm from './wasm_bg';
const __wbg_f_log_log_n_target = console.log;
let cachedDecoder = new TextDecoder('utf-8');
let cachedUint8Memory = null;
function getUint8Memory() {
if (cachedUint8Memory === null ||
@FreeMasen
FreeMasen / comments.json
Created June 17, 2018 16:51
wasm-bindgen custom section format
[
{
"exports": [],
"enums": [],
"imports": [],
"structs": [
{
"name": "Comment",
"fields": [
{
x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeT
let wasm;
fetch('/rust_program_name.wasm')
.then(res => res.arrayBuffer())
.then(buf => {
return WebAssembly.Instantiate(buf, importObject)
.then(mod => {
wasm = mod.instance.exports;
start();
});
});
enum Expression {
Binary(BinaryExpression),
Unary(Box<UnaryExpression>),
}
struct BinaryExpression {
left: Box<Expression>,
operator: Operator,
right: Box:<Expression>,
}
@FreeMasen
FreeMasen / Cargo.toml
Last active September 25, 2018 05:04
getpid
[package]
name = "getpid"
version = "0.1.0"
[dependencies]
walkdir = "1"
docopt = "2"
INFO 2018-09-25T19:54:22Z: analytics: Starting up
INFO 2018-09-25T19:54:22Z: warp::server: warp drive engaged: listening on 127.0.0.1:5555
INFO 2018-09-25T19:54:33Z: warp::filters::log: "POST /analytics/landing HTTP/1.1" 400 720.83
#[macro_use]
extern crate nom;
type Duration = Vec<(f32, DurationUnit)>;
pub fn parse(s: &str) -> Result<Duration, String> {
match parse_duration(s) {
Ok(pair) => {
Ok(pair.1)
},
Err(e) => Err(format!("Error parsing duration {:?}", e)),
}