Fix a type error. Fix the binary build script - #10
Conversation
|
I'll post some questions below about some issues i'm having in understanding the old original code, the one in the |
So, this is your "original code" in the This is the old code in I am unable to fix this compile error no matter what i've tried. Any idea on how I could fix it? |
|
Hey @vtrofin and thank you for the heads up. Indeed, while the code compile just fine on Windows It'll fail on other platforms as |
If you refer to the code that was on my repo before the last couple of prs, notice that the code is not the same as Scoville's (if my memory serves me well). Also, this crate now requires Rust 1.68 (soon 1.68.2) to compile, and if you try to compile it with this version of Rust you might get different compile errors reported than the version used at the time. Also, that that macro got dropped and Neon replaced by Napi (which I find paradoxally more user friendly yet more barebone 😅). As for the error itself, notice that Now, what's interesting is to see where that error comes from: Neon got a patch update from 0.10.0-alpha.-* (the version we used to use) and 0.10.0 and 0.10.1 (the version that cargo downloaded since the version specified is 0.10) that's breaking. 0.10.0-alpha.1: https://docs.rs/neon/0.10.0-alpha.1/neon/object/trait.Object.html#method.get
The fix could look like this: macro_rules! get {
($cx:ident, $options:ident, $name:expr, $type:ty) => {
let value = options
.get::<$type, _, _>(&mut $cx, $name)?;
value
};
($cx:ident, $options:ident, $name:expr) => {
get!($cx, $options, $name, JsString)
};
}But at that point the macro is useless (and actually always has been) and I would recommend dropping it. You can deref the returned value or take ownership: let value = get!(...);
let value_ref = *value; // will be &String for a String
let value_owned = value.to_owned(); // will be String for, well, String, implies a cloneI would also pin the version in the Cargo.toml for this crate. Side note, here is a reduction of the macro using only Rust's std: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=bcd20fe60189b4784e7a779a5cf0b88e |
|
Thank you for your suggestions @gaku-sei . I ended up reusing the let capture_regex = options
.get::<JsString, FunctionContext, _>(&mut cx, "captureRegex")?
.value(&mut cx);I also made the suggested type update and added some updates to the release workflow in order to handle Mac M1s. Ready for your review. |
| @if ! command -v cross &> /dev/null; then \ | ||
| cargo install cross --git https://github.com/cross-rs/cross; \ | ||
| fi | ||
| yarn |
There was a problem hiding this comment.
could be improved to first check whether yarn is installed and if not use npm -i instead of yarn
@gaku-sei i'm opening a PR here because I can't create issues on your
gaku-sei/pyacorepo.