mirror of
https://github.com/openharmony/third_party_rust_mime.git
synced 2026-06-30 21:47:57 -04:00
add a usage example to README
This commit is contained in:
+6
-10
@@ -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
|
||||
|
||||
@@ -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!
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user