add a usage example to README

This commit is contained in:
Sean McArthur
2017-09-19 11:58:29 -07:00
parent bbe4359f27
commit 2fc4d3e5f3
2 changed files with 26 additions and 10 deletions
+6 -10
View File
@@ -7,17 +7,13 @@ matrix:
- rust: stable
- rust: beta
- rust: nightly
- rust: 1.15.0
sudo: false
dist: trusty
cache: cargo
cache:
apt: true
directories:
- target/debug/deps
- target/debug/build
notifications:
email: false
script:
- cargo build
- cargo test
- rustdoc --test README.md -L target/debug/deps
+20
View File
@@ -8,4 +8,24 @@ Support MIME (Media Types) as strong types in Rust.
[Documentation](https://docs.rs/mime)
## Usage
```rust
extern crate mime;
// common types are constants
let text = mime::TEXT_PLAIN;
// deconstruct Mimes to match on them
match (text.type_(), text.subtype()) {
(mime::TEXT, mime::PLAIN) => {
// plain text!
},
(mime::TEXT, _) => {
// structured text!
},
_ => {
// not text!
}
}
```