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

Cannot use #[deriving(Encodable)] on unit-like struct #14021

Closed
andrewd18 opened this issue May 7, 2014 · 0 comments · Fixed by #14596
Closed

Cannot use #[deriving(Encodable)] on unit-like struct #14021

andrewd18 opened this issue May 7, 2014 · 0 comments · Fixed by #14596

Comments

@andrewd18
Copy link

I have a nested data structure with a few unit-like structs as placeholders. When I tried to encode the structure, I received a "not all control paths return a value" when using #[deriving(Encodable] on said unit-like structs. Works great when I take said structs out or give them data.

Unsure if bug or feature.

extern crate serialize;
use serialize::{json};

#[deriving(Encodable)]
struct UnitLikeStruct;

fn main() {
    let to_encode_object = UnitLikeStruct;
    let encoded_str: ~str = json::Encoder::str_encode(&to_encode_object);

    println!("{}", encoded_str);
}

Using a slightly older pre-nightly on Windows 7:
C:\Program Files (x86)\Rust\bin\rustc.exe 0.11-pre-nightly (1853619 2014-04-17 01:31:27 -0700)

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

Successfully merging a pull request may close this issue.

1 participant