3
私はserdeマクロを使用してJSONをシリアライズしようとしているが、私はこのエラーを取得:Serde JSONのシリアル化エラー?
src/models/pulse.rs:89:28: 89:49 error: the trait bound `models::pulse::Pulse: serde::ser::Serialize` is not satisfied [E0277]
src/models/pulse.rs:89 if let Ok(bulk_string) = serde_json::to_string(&self) {
^~~~~~~~~~~~~~~~~~~~~
src/models/pulse.rs:89:28: 89:49 help: run `rustc --explain E0277` to see a detailed explanation
src/models/pulse.rs:89:28: 89:49 note: required because of the requirements on the impl of `serde::ser::Serialize` for `&mut models::pulse::Pulse`
src/models/pulse.rs:89:28: 89:49 note: required by `serde_json::to_string`
私はコードで間違った何かを持っていないようです。
#[derive(Serialize, Deserialize)]
pub struct Pulse {
#[serde(skip_serializing_if="Option::is_none")]
id: Option<u64>,
#[serde(skip_serializing_if="Option::is_none")]
category: Option<i64>,
#[serde(skip_serializing_if="Option::is_none")]
title: Option<String>,
}
これは依存関係のエラーですか?または、私のコードに何か問題がありますか?私は使用する
[dependencies.serde]
git = "https://github.com/serde-rs/serde.git"
[dependencies.serde_macros]
git = "https://github.com/serde-rs/serde.git"
[dependencies.serde_json]
git = "https://github.com/serde-rs/json.git"
なぜ私はgitの依存関係を使用するのか疑問がありました。理由は、私が得ることです:
/.cargo/registry/src/github.com-1ecc6299db9ec823/aster-
0.18.0/src/mac.rs:6:5: 6:39 error: unresolved import `syntax::feature_gate::GatedCfgAttr`. There is no `GatedCfgAttr` in `syntax::feature_gate`. Did you mean to use `GatedCfg`? [E0432]
/.cargo/registry/src/github.com-1ecc6299db9ec823/aster-0.18.0/src/mac.rs:6 use syntax::feature_gate::GatedCfgAttr;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/.cargo/registry/src/github.com-1ecc6299db9ec823/aster-0.18.0/src/mac.rs:6:5: 6:39 help: run `rustc --explain E0432` to see a detailed explanation
Compiling num-traits v0.1.32
/.cargo/registry/src/github.com-1ecc6299db9ec823/aster-0.18.0/src/mac.rs:113:18: 113:81 error: this function takes 4 parameters but 5 parameters were supplied [E0061]
/.cargo/registry/src/github.com-1ecc6299db9ec823/aster-0.18.0/src/mac.rs:113 let mut cx = ExtCtxt::new(sess, cfg, ecfg, feature_gated_cfgs, macro_loader);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/.cargo/registry/src/github.com-1ecc6299db9ec823/aster-0.18.0/src/mac.rs:113:18: 113:81 help: run `rustc --explain E0061` to see a detailed explanation
/.cargo/registry/src/github.com-1ecc6299db9ec823/aster-0.18.0/src/mac.rs:113:18: 113:81 note: the following parameter types were expected: &syntax::parse::ParseSess, std::vec::Vec<syntax::ptr::P<syntax::codemap::Spanned<syntax::ast::MetaItemKind>>>, syntax::ext::expand::ExpansionConfig<'_>, &mut syntax::ext::base::MacroLoader
私は問題が夜間使用する必要がありますことができると思う。
なぜあなたは 'git'依存関係を使用していますか?あなたはcrates.ioを通してそれらを使用するべきです。 –
クレートを使用すると、別のエラーが発生します。 @ker私は今質問を更新しました。 – user3384741
'cargo update'(昨日修正されていた問題は夜間にしか起こらず、安定したコンパイラを使用しています) –