mirror of https://git.sr.ht/~stygianentity/bincode
added old_orphan_check feature to tests and examples
This commit is contained in:
parent
6e0069163c
commit
b873c9e75f
|
|
@ -17,16 +17,18 @@ library.
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
#![feature(old_orphan_check)]
|
||||||
|
|
||||||
extern crate bincode;
|
extern crate bincode;
|
||||||
extern crate "rustc-serialize" as rustc_serialize;
|
extern crate "rustc-serialize" as rustc_serialize;
|
||||||
|
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq)]
|
||||||
struct Entity {
|
struct Entity {
|
||||||
x: f32,
|
x: f32,
|
||||||
y: f32,
|
y: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq)]
|
||||||
struct World {
|
struct World {
|
||||||
entities: Vec<Entity>
|
entities: Vec<Entity>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
|
#![feature(old_orphan_check)]
|
||||||
|
|
||||||
extern crate bincode;
|
extern crate bincode;
|
||||||
extern crate "rustc-serialize" as rustc_serialize;
|
extern crate "rustc-serialize" as rustc_serialize;
|
||||||
|
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq)]
|
||||||
struct Entity {
|
struct Entity {
|
||||||
x: f32,
|
x: f32,
|
||||||
y: f32,
|
y: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq)]
|
||||||
struct World {
|
struct World {
|
||||||
entities: Vec<Entity>
|
entities: Vec<Entity>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#![crate_name = "bincode"]
|
#![crate_name = "bincode"]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![crate_type = "dylib"]
|
#![crate_type = "dylib"]
|
||||||
|
#![feature(old_orphan_check)]
|
||||||
|
|
||||||
extern crate "rustc-serialize" as rustc_serialize;
|
extern crate "rustc-serialize" as rustc_serialize;
|
||||||
|
|
||||||
|
|
|
||||||
12
src/test.rs
12
src/test.rs
|
|
@ -65,7 +65,7 @@ fn test_tuple() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_basic_struct() {
|
fn test_basic_struct() {
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
||||||
struct Easy {
|
struct Easy {
|
||||||
x: int,
|
x: int,
|
||||||
s: String,
|
s: String,
|
||||||
|
|
@ -76,13 +76,13 @@ fn test_basic_struct() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nested_struct() {
|
fn test_nested_struct() {
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
||||||
struct Easy {
|
struct Easy {
|
||||||
x: int,
|
x: int,
|
||||||
s: String,
|
s: String,
|
||||||
y: uint
|
y: uint
|
||||||
}
|
}
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
||||||
struct Nest {
|
struct Nest {
|
||||||
f: Easy,
|
f: Easy,
|
||||||
b: uint,
|
b: uint,
|
||||||
|
|
@ -98,7 +98,7 @@ fn test_nested_struct() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_struct_tuple() {
|
fn test_struct_tuple() {
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
||||||
struct TubStr(uint, String, f32);
|
struct TubStr(uint, String, f32);
|
||||||
|
|
||||||
the_same(TubStr(5, "hello".to_string(), 3.2));
|
the_same(TubStr(5, "hello".to_string(), 3.2));
|
||||||
|
|
@ -113,7 +113,7 @@ fn option() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn enm() {
|
fn enm() {
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
||||||
enum TestEnum {
|
enum TestEnum {
|
||||||
NoArg,
|
NoArg,
|
||||||
OneArg(uint),
|
OneArg(uint),
|
||||||
|
|
@ -127,7 +127,7 @@ fn enm() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn struct_enum() {
|
fn struct_enum() {
|
||||||
#[deriving(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
#[derive(RustcEncodable, RustcDecodable, PartialEq, Show)]
|
||||||
enum TestEnum {
|
enum TestEnum {
|
||||||
NoArg,
|
NoArg,
|
||||||
OneArg(uint),
|
OneArg(uint),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue