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

Macros support #16

Closed
frol opened this issue Sep 29, 2018 · 1 comment
Closed

Macros support #16

frol opened this issue Sep 29, 2018 · 1 comment

Comments

@frol
Copy link

frol commented Sep 29, 2018

It seems that something is going wrong with the macros. Here is what I put in a single Jupyter cell:

#[macro_use]
extern crate serde_derive;

extern crate serde;
extern crate serde_json;

#[derive(Serialize, Deserialize, Debug)]
pub struct Point {
    pub x: i32,
    pub y: i32,
}

Output:

#[derive(Serialize, Deserialize, Debug)]
                    ^^^^^^^^^^^ 
cannot find derive macro `Deserialize` in this scope

#[derive(Serialize, Deserialize, Debug)]
         ^^^^^^^^^ 
cannot find derive macro `Serialize` in this scope
@frol
Copy link
Author

frol commented Sep 29, 2018

Well, this might be not a big deal since extern crate and macro_use will essentially go away in Rust 2018 edition. I successfully run Rust Beta (1.30) and use use statement to import macros:

$ rustup run beta evcxr
Welcome to evcxr. For help, type :help
>> extern crate serde;
>> extern crate serde_derive;
>> extern crate serde_json;
>> use serde_derive::{Serialize, Deserialize};
>> #[derive(Debug, Serialize, Deserialize)] pub struct Point { pub x: i32, pub y: i32 }
>> let p1 = Point { x: 10, y: 20 };
>> p1
Point { x: 10, y: 20 }
>> serde_json::to_string(&p1)
Ok("{\"x\":10,\"y\":20}")

@frol frol closed this as completed Sep 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant