Remove error-chain from examples having only one error variant (#531)

* Rmove error-chain from examples having only one error variant

Remove error_chain from csv example 'Serde deserializes data into ...'
Remove error_chain from toml example 'Parse TOML into your ...'

* remove linebreak after main

* remove line break
This commit is contained in:
Thomas Mulvaney 2019-09-20 00:14:38 +01:00 committed by Andrew Gauger
parent d3a407a433
commit 9c72aecdfc
2 changed files with 3 additions and 18 deletions

View file

@ -34,12 +34,11 @@ fn main() -> Result<(), Error> {
Parse TOML into your own structs using [Serde]. Parse TOML into your own structs using [Serde].
```rust ```rust
# #[macro_use]
# extern crate error_chain;
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
extern crate toml; extern crate toml;
use toml::de::Error;
use std::collections::HashMap; use std::collections::HashMap;
#[derive(Deserialize)] #[derive(Deserialize)]
@ -54,14 +53,8 @@ struct Package {
version: String, version: String,
authors: Vec<String>, authors: Vec<String>,
} }
#
# error_chain! {
# foreign_links {
# Toml(toml::de::Error);
# }
# }
fn main() -> Result<()> { fn main() -> Result<(), Error> {
let toml_content = r#" let toml_content = r#"
[package] [package]
name = "your_package" name = "your_package"

View file

@ -36,17 +36,9 @@ Serde deserializes data into strongly type structures. See the
```rust ```rust
extern crate csv; extern crate csv;
# #[macro_use]
# extern crate error_chain;
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
# error_chain! {
# foreign_links {
# Reader(csv::Error);
# }
# }
#
#[derive(Deserialize)] #[derive(Deserialize)]
struct Record { struct Record {
year: u16, year: u16,
@ -55,7 +47,7 @@ struct Record {
description: String, description: String,
} }
fn main() -> Result<()> { fn main() -> Result<(), csv::Error> {
let csv = "year,make,model,description let csv = "year,make,model,description
1948,Porsche,356,Luxury sports car 1948,Porsche,356,Luxury sports car
1967,Ford,Mustang fastback 1967,American car"; 1967,Ford,Mustang fastback 1967,American car";