-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add #[wasm_bindgen(ignore)]
to ignore a pub
field and not generate getters/setters for it
#1284
Comments
Hey @lrlna -- thanks for filing an issue. Right now, whenever there is a We could add a #[wasm_bindgen]
pub struct Parser {
pub count: usize,
#[wasm_bindgen(ignore)]
pub fields: HashMap<String, Field>,
} In the meantime, you can get your example code working by either
|
#[wasm_bindgen(ignore)]
to ignore a pub
field and not generate getters/setters for it
Ohhhhh that's really interesting, but totally makes sense. I guess I was trying to avoid running into trouble with Having it not be a Thanks so much for your help, @fitzgen ! |
So is adding I can take on this issue with some guidance! |
Correct!
I think that should be enough to get you started, but don't hesitate to ask any more questiosn! |
It's taking some time to figure out how everything works. I have a couple of questions.
I'm having a little trouble piecing together how the bindgen attribute stuff is working, so I apologize if these questions don't make sense. Thanks! |
@tyleranton yeah you'll want to add You'll later read that just below here. You're interested in the attributes of the field though, so just before you read it out you'll want to execute: let attrs = BindgenAttrs::find(&mut field.attrs)?;
let ignored = attrs.ignore();
attrs.check_used()?;
if ignored {
continue;
} |
Should this be named |
Don't we have a regression here? use wasm_bindgen::prelude::*;
use base::model;
#[wasm_bindgen]
pub struct Viewer {}
#[wasm_bindgen]
impl Viewer {
pub fn from_model_stream(
_stream: &web_sys::ReadableStream,
) -> Result<Viewer, JsValue> {
Ok(Viewer {})
}
#[wasm_bindgen(skip)]
pub fn from_model(_model: &model::Model) -> Result<Viewer, JsValue> {
Ok(Viewer {})
}
pub fn start(
&mut self,
_canvas: &web_sys::HtmlCanvasElement,
) -> Result<(), JsValue> {
Ok(())
}
} gives
|
I ran into the same issue, but the answer in StackOverflow helped |
Hello!
I am attempting to use a HashMap inside a wrapper struct, but running into a conversion error.
Code to reproduce:
Running
wasm-pack build
causes this error:I know the guide on Arbitrary Data Structures mentions to remove the
#[wasm_bindgen]
macro around the struct, but doing that also errors out.Adjusted
Parser
Struct (and everything else from example stays the same):Error:
Thank you for your time!
The text was updated successfully, but these errors were encountered: