Skip to content
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

Implement Native JSClasses #113

Open
yancheng199287 opened this issue Apr 14, 2021 · 2 comments
Open

Implement Native JSClasses #113

yancheng199287 opened this issue Apr 14, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@yancheng199287
Copy link

I want to add struct,like this:

struct User {
    username: String,
    email: String,
    sign_in_count: u64,
    active: bool,
}

fn build_user(email: String, username: String) -> User {
    User {
        email,
        username,
        active: true,
        sign_in_count: 1,
    }
}

impl User{
    
    fn introduce(self){
        println!("{} {}",self.username,self.email)
    }
}

and I want to use User in JS , like this

let user=new User("Jason","[email protected]",false,10);
user.introduce();

how to do it? thanks!

@yancheng199287
Copy link
Author

maybe need support JS_NewClass? Consider implementing this data type?

@theduke theduke added the enhancement New feature or request label Apr 23, 2021
@theduke theduke changed the title how to add struct to bind js class? Implement Native JSClasses Apr 23, 2021
@theduke
Copy link
Owner

theduke commented Apr 23, 2021

maybe need support JS_NewClass? Consider implementing this data type?

Correct. This is not implemented yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants