Skip to content

Commit

Permalink
Readme changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomcc authored Dec 1, 2024
1 parent 3c1df78 commit f2c2c5f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Quick and dirty crate for parsing values out of an environment var provided at
compile time. See also: [docs](https://docs.rs/envparse).

Feel free to [email me](chiovolonit@gmail.com) if I fail to notice a PR or issue in this
repository (my github notifications are a mess).

## Usage
Here's an example
```rs
Expand All @@ -23,7 +26,10 @@ struct Thing {
}
```

You can also `try`
You can also `try` to parse the value, which always returns an Option. Note that if the user
provided the value, but it was out of range, this will still fail with a compile error (rather
than returning `None`), in order to let them know that their configuration was not/cannot be
respected.

```rs
const MAX_LEN_LOG2: u32 = match envparse::parse_env!(try "OPTIONAL_MAX_LEN_LOG2" as u32 in 0..32) {
Expand All @@ -35,6 +41,3 @@ struct Thing {
len: [u8; MAX_LEN],
}
```

```

0 comments on commit f2c2c5f

Please sign in to comment.