mirror of
https://github.com/rust-lang-nursery/rust-cookbook
synced 2024-11-21 19:13:07 +00:00
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:
parent
d3a407a433
commit
9c72aecdfc
2 changed files with 3 additions and 18 deletions
|
@ -34,12 +34,11 @@ fn main() -> Result<(), Error> {
|
|||
Parse TOML into your own structs using [Serde].
|
||||
|
||||
```rust
|
||||
# #[macro_use]
|
||||
# extern crate error_chain;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate toml;
|
||||
|
||||
use toml::de::Error;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -54,14 +53,8 @@ struct Package {
|
|||
version: String,
|
||||
authors: Vec<String>,
|
||||
}
|
||||
#
|
||||
# error_chain! {
|
||||
# foreign_links {
|
||||
# Toml(toml::de::Error);
|
||||
# }
|
||||
# }
|
||||
|
||||
fn main() -> Result<()> {
|
||||
fn main() -> Result<(), Error> {
|
||||
let toml_content = r#"
|
||||
[package]
|
||||
name = "your_package"
|
||||
|
|
|
@ -36,17 +36,9 @@ Serde deserializes data into strongly type structures. See the
|
|||
|
||||
```rust
|
||||
extern crate csv;
|
||||
# #[macro_use]
|
||||
# extern crate error_chain;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
# error_chain! {
|
||||
# foreign_links {
|
||||
# Reader(csv::Error);
|
||||
# }
|
||||
# }
|
||||
#
|
||||
#[derive(Deserialize)]
|
||||
struct Record {
|
||||
year: u16,
|
||||
|
@ -55,7 +47,7 @@ struct Record {
|
|||
description: String,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
fn main() -> Result<(), csv::Error> {
|
||||
let csv = "year,make,model,description
|
||||
1948,Porsche,356,Luxury sports car
|
||||
1967,Ford,Mustang fastback 1967,American car";
|
||||
|
|
Loading…
Reference in a new issue