fengcen / arthas

[ABANDONED] An in-memory structure database for Rust.
MIT License
18 stars 1 forks source link

Unable to run the example: can't find crate for `_serde` #4

Closed umayr closed 7 years ago

umayr commented 7 years ago

I have the following versions of rustc and cargo:

(master) λ rustc --version
rustc 1.18.0 (03fc9d622 2017-06-06)

(master) λ cargo --version
cargo 0.19.0 (28d1d60d4 2017-05-16)

Using the example:

extern crate arthas;
#[macro_use]
extern crate arthas_derive;
#[macro_use]
extern crate serde_derive;

use arthas::prelude::*;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, Arthas)]
pub struct Article {
    pub _id: String,
    pub title: String,
    pub content: String,
    pub views: usize,
}

impl Article {
    pub fn new<T: Into<String>>(title: T) -> Article {
        Article { title: title.into(), ..Default::default() }
    }
}

fn main() {
    // Disable persistence for the tests.
    arthas::config::persistence(false);

    // Insert
    let id = Article::session().insert(Article::new("Hello world!")).unwrap();

    // Update
    Article::session().id(&id).update(|article| article.views = 10).unwrap();

    // Find
    let items = Article::session().find().unwrap();
    assert!(items.len() > 0);

    // Find One
    let item = Article::session().id(&id).find_one().unwrap();
    assert!(item.is_some());
    assert_eq!(item.unwrap().title, "Hello world!");

    // Remove
    Article::session().id(&id).remove().unwrap();
}

cargo.toml file:

...
[dependencies]
arthas = "^0.3"
arthas_derive = "^0.1"
serde_derive = "^0.9"

Ending up getting the following error:

(master) λ cargo check                                                                                                                                                                                            (arthas-test) 15:51:31
   Compiling serde v0.8.23
   Compiling itoa v0.3.1
   Compiling scopeguard v0.1.2
   Compiling dtoa v0.4.1
   Compiling serde v0.9.15
   Compiling variance v0.1.3
   Compiling num-traits v0.1.40
   Compiling glob v0.2.11
   Compiling byteorder v0.3.13
   Compiling rustc-serialize v0.3.24
   Compiling num-integer v0.1.35
   Compiling quick-error v1.2.0
   Compiling vec_map v0.6.0
   Compiling libc v0.2.26
   Compiling hostname v0.1.3
   Compiling num_cpus v1.6.2
   Compiling thread-id v3.2.0
   Compiling rand v0.3.15
   Compiling crossbeam v0.2.10
   Compiling scoped-pool v1.0.0
   Compiling time v0.1.38
   Compiling num-iter v0.1.34
   Compiling num v0.1.40
   Compiling odds v0.2.25
   Compiling nodrop v0.1.9
   Compiling byteorder v1.1.0
   Compiling void v1.0.2
   Compiling unreachable v0.1.1
   Compiling quickersort v2.2.0
   Compiling memmap v0.5.2
   Compiling bincode v0.6.1
   Compiling lazy_static v0.2.8
   Compiling log v0.3.8
   Compiling rust-crypto v0.2.36
   Compiling libc v0.1.12
   Compiling chrono v0.2.25
   Compiling serde_json v0.9.10
   Compiling objectid v0.1.0
   Compiling arthas v0.3.0
   Compiling arthas-test v0.1.0 (file:///private/tmp/arthas-test)
error[E0463]: can't find crate for `_serde`
 --> src/main.rs:9:55
  |
9 | #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, Arthas)]
  |                                                       ^^^^^^^^^^^ can't find crate

error: aborting due to previous error
umayr commented 7 years ago

After including serde in the cargo.toml file:

...
[dependencies]
arthas = "^0.3"
arthas_derive = "^0.1"
serde = "^0.9"
serde_derive = "^0.9"

It gets fixed. Probably need to update the docs?

fengcen commented 7 years ago

Ok, I'll check it out. Thanks.