Giter VIP home page Giter VIP logo

Comments (2)

juntao avatar juntao commented on May 30, 2024

This indicates a runtime error in your Rust code. Can you post a gist of your lib.rs file?

from wasm-learning.

Tippon avatar Tippon commented on May 30, 2024

Thanks for the reply :)

I just noticed that I'd somehow missed the first two lines, so mine was

#[wasm_bindgen] pub fn solve(params: &str) -> String { let ps: (f32, f32, f32) = serde_json::from_str(&params).unwrap(); let discriminant: f32 = (ps.1 * ps.1) - (4. * ps.0 * ps.2); let mut solution: (f32, f32) = (0., 0.); if discriminant >= 0. { solution.0 = (((-1.) * ps.1) + discriminant.sqrt()) / (2. * ps.0); solution.1 = (((-1.) * ps.1) - discriminant.sqrt()) / (2. * ps.0); return serde_json::to_string(&solution).unwrap(); } else { return String::from("not real numbers"); } }

but I've just changed it to include the missing lines. Using VS on Windows 10 or Ubuntu 20.04 still gives the error above.

I'm pretty much brand new to this, so there's a good chance that I've got something basic wrong. At the beginning of the Getting started with Rust functions in Node.js article I used the git clone https://github.com/second-state/ssvm-nodejs-starter command to get the files, so tried the same with the quadratic equation example, but it wouldn't work. Googling told me to go to the root, so wasm-learning, and use git clone there. I've then gone to the nodejs/quadratic/ folder and worked from there, including telling VS to open it in the terminal. As far as I can tell, everything has run from that folder.

from wasm-learning.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.