Skip to content

Commit e8bee78

Browse files
bors[bot]Tehnix
andauthored
Merge #521
521: Update Uuid::new_v4 documentation to reflect `Try` no longer being implemented r=KodrAus a=Tehnix <!-- If this PR is a breaking change, ensure that you are opening it against the `breaking` branch. If the pull request is incomplete, prepend the Title with WIP: --> **I'm submitting a(n)** other (documentation fix) # Description The current example at https://docs.rs/uuid/0.8.2/uuid/index.html#examples to generate a UUIDV4 currently does not compile, given that `Uuid` no longer implements `Try`. This PR updates the example to match the one given in the README of this repo, along with enabling testing for it again to ensure it doesn't go out of date. I've run `cargo test --all-features` to ensure that the tests do indeed pass. Finally, we also hide the configuration flags, `#[cfg(feature = "v4")]`, from the example, since it should not be copied by the user of the crate, if they wanted to use the example. # Motivation I was looking to generate a UUID V4 and unfortunately the examples in https://docs.rs/uuid/0.8.2/uuid/index.html#examples were out-of-date. # Tests <!-- How are these changes tested? --> This enables the doc-test that was already there, which now compiles after updating the code in the example. # Related Issue(s) None that I'm aware of Co-authored-by: Christian Kjær <[email protected]> Co-authored-by: Christian Kjaer Laustsen <[email protected]>
2 parents 3b5f6ad + a0dcc9b commit e8bee78

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,16 @@
8787
//!
8888
//! To create a new random (V4) UUID and print it out in hexadecimal form:
8989
//!
90-
//! ```ignore,rust
90+
//! ```rust
9191
//! // Note that this requires the `v4` feature enabled in the uuid crate.
9292
//!
9393
//! use uuid::Uuid;
9494
//!
95-
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
96-
//! #[cfg(feature = "v4")] {
97-
//! let my_uuid = Uuid::new_v4()?;
98-
//! println!("{}", my_uuid);
99-
//! }
100-
//! Ok(())
95+
//! fn main() {
96+
//! # #[cfg(feature = "v4")] {
97+
//! let my_uuid = Uuid::new_v4();
98+
//! println!("{}", my_uuid)
99+
//! # }
101100
//! }
102101
//! ```
103102
//!

0 commit comments

Comments
 (0)