Benign cargo Download

rational_numbers.rs

SHA-25665c93e277cffe0310803e64c948e263d1f833bf70b6628c68497c83c0be134a7
Malecule∅

Evidence

English function-word token "this" lines 1–2
1//! This example shows how to write your own custom implementation of
2//! `Decodable` to parse rational …
imports regex::Regex lines 8–27
8:9… rate "rustc-serialize" as rustc_serialize;
9
10use std::str;
11
12use regex::Regex;
13use rustc_serialize::{Decodable, Decoder};
14
15#[derive(Debug)]
16struct Rational {
17 numerator: i64,
18 denominator: i64,
19}
20
21impl Decodable for Rational {
22 fn decode<D: Decoder>(d: &mut D) -> Result<Rational, D::Error> {
23 let field = try!(d.read_str());
24 // This uses the `FromStr` impl below.
25 match field.parse() {
26 Ok(rat) => Ok(rat),
27 …

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.