Skip to content

Commit ff2d103

Browse files
committed
Add example to crate documentation
1 parent 1af2b78 commit ff2d103

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

enum-iterator-derive/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
// Copyright (C) 2018-2019 Stephane Raux. Distributed under the 0BSD license.
1+
// Copyright (C) 2018-2021 Stephane Raux. Distributed under the 0BSD license.
22

3+
//! # Overview
4+
//! - [📦 crates.io](https://crates.io/crates/enum-iterator-derive)
5+
//! - [📖 Documentation](https://docs.rs/enum-iterator-derive)
6+
//! - [⚖ 0BSD license](https://spdx.org/licenses/0BSD.html)
7+
//!
38
//! Procedural macro to derive `IntoEnumIterator` for field-less enums.
49
//!
510
//! See crate [enum-iterator](https://docs.rs/enum-iterator) for details.
11+
//!
12+
//! # Contribute
13+
//! All contributions shall be licensed under the [0BSD license](https://spdx.org/licenses/0BSD.html).
614
715
#![recursion_limit = "128"]
816
#![deny(warnings)]

enum-iterator/src/lib.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
// Copyright (C) 2018-2019 Stephane Raux. Distributed under the 0BSD license.
1+
// Copyright (C) 2018-2021 Stephane Raux. Distributed under the 0BSD license.
22

3+
//! # Overview
4+
//! - [📦 crates.io](https://crates.io/crates/enum-iterator)
5+
//! - [📖 Documentation](https://docs.rs/enum-iterator)
6+
//! - [⚖ 0BSD license](https://spdx.org/licenses/0BSD.html)
7+
//!
38
//! Tools to iterate over the variants of a field-less enum.
49
//!
5-
//! See the `IntoEnumIterator` trait.
10+
//! See the [`IntoEnumIterator`] trait.
11+
//!
12+
//! # Example
13+
//! ```
14+
//! use enum_iterator::IntoEnumIterator;
15+
//!
16+
//! #[derive(Debug, IntoEnumIterator, PartialEq)]
17+
//! enum Day { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }
18+
//!
19+
//! fn main() {
20+
//! assert_eq!(Day::into_enum_iter().next(), Some(Day::Monday));
21+
//! assert_eq!(Day::into_enum_iter().last(), Some(Day::Sunday));
22+
//! }
23+
//! ```
24+
//!
25+
//! # Contribute
26+
//! All contributions shall be licensed under the [0BSD license](https://spdx.org/licenses/0BSD.html).
627
728
#![deny(missing_docs)]
829
#![deny(warnings)]
@@ -24,7 +45,7 @@ use core::iter;
2445
/// use enum_iterator::IntoEnumIterator;
2546
///
2647
/// #[derive(Clone, IntoEnumIterator, PartialEq)]
27-
/// enum Direction {North, South, West, East}
48+
/// enum Direction { North, South, West, East }
2849
///
2950
/// fn main() {
3051
/// assert_eq!(Direction::VARIANT_COUNT, 4);

0 commit comments

Comments
 (0)