4 releases
0.2.0 | Jul 31, 2019 |
---|---|
0.1.2 | Jul 31, 2019 |
0.1.1 | Jul 31, 2019 |
0.1.0 | Jul 31, 2019 |
#8 in #get
23 downloads per month
7KB
93 lines
xkcd_get
xkcd_get
provides a simple way of retrieving xkcd comic information.
Cargo
[dependencies]
xkcd_get = "0.2.0"
Usage
use xkcd_get::Comic;
fn main () {
let data = Comic::get(10).unwrap();
let data_latest = Comic::latest().unwrap();
println!("Comic 10 was titled {}! xkcd is now on comic {}! Wow!", data.title, data_latest.num);
}
lib.rs
:
xkcd_get
gives access to xkcd's JSON API through the Comic
struct.
Basic examples are provided on this page, see the Comic
struct's page for specifics.
Examples
Getting the Latest Comic
use xkcd_get::Comic;
fn main () {
let data = Comic::latest().unwrap();
println!("Comic Number {}: '{}'", data.num, data.title);
}
Getting a Comic by Number
use xkcd_get::Comic;
fn main () {
let data = Comic::get(327).unwrap();
println!("Comic Number {}: '{}'", data.num, data.title);
// Comic Number 327: 'Exploits of a Mom'
}
Dependencies
~23MB
~472K SLoC