]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass-fulldeps/issue-11881.rs
Ignore new test on Windows
[rust.git] / src / test / run-pass-fulldeps / issue-11881.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 #![feature(rustc_private)]
13
14 extern crate serialize;
15
16 use std::io::Cursor;
17 use std::io::prelude::*;
18 use std::fmt;
19 use std::slice;
20
21 use serialize::{Encodable, Encoder};
22 use serialize::json;
23 use serialize::opaque;
24
25 #[derive(Encodable)]
26 struct Foo {
27     baz: bool,
28 }
29
30 #[derive(Encodable)]
31 struct Bar {
32     froboz: usize,
33 }
34
35 enum WireProtocol {
36     JSON,
37     Opaque,
38     // ...
39 }
40
41 fn encode_json<T: Encodable>(val: &T, wr: &mut Cursor<Vec<u8>>) {
42     write!(wr, "{}", json::as_json(val));
43 }
44 fn encode_opaque<T: Encodable>(val: &T, wr: Vec<u8>) {
45     let mut encoder = opaque::Encoder::new(wr);
46     val.encode(&mut encoder);
47 }
48
49 pub fn main() {
50     let target = Foo{baz: false,};
51     let proto = WireProtocol::JSON;
52     match proto {
53         WireProtocol::JSON => encode_json(&target, &mut Cursor::new(Vec::new())),
54         WireProtocol::Opaque => encode_opaque(&target, Vec::new())
55     }
56 }