Skip to content

Commit dfa6acd

Browse files
feat: add test feature for typed-uuid's new_unchecked method
1 parent 6e89db2 commit dfa6acd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

benzina/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ serde = ["dep:serde", "uuid?/serde"]
3636
utoipa = ["dep:utoipa"]
3737

3838
example-generated = ["typed-uuid"]
39+
test = ["typed-uuid"]
3940

4041
[lints]
4142
workspace = true

benzina/src/typed_uuid.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/// The generated structs do not expose any method or trait to create an arbitrary instance[^See note], in
88
/// order to provide the guarantee that the `UUID` is valid. However, it is possible to choose to
99
/// add traits and methods to customize the behavior.
10+
///
1011
#[cfg_attr(
1112
not(feature = "example-generated"),
1213
doc = "To see the documentation of a generated typed `UUID`, consider re-building the \
@@ -63,7 +64,8 @@
6364
/// ```
6465
///
6566
/// [^See note]: There is no way in normal usage to construct an instance. The exception is with the
66-
/// `new_unchecked` method, which is intended for special cases, such as testing.
67+
/// `new_unchecked` method, which is gated behind the `test` feature and intended for special cases
68+
/// (including testing).
6769
#[macro_export]
6870
macro_rules! typed_uuid {
6971
(
@@ -92,6 +94,7 @@ macro_rules! typed_uuid {
9294
impl $name {
9395
/// Creates a new, unchecked typed Uuid
9496
#[must_use]
97+
#[cfg(feature = "test")]
9598
pub fn new_unchecked(inner: ::uuid::Uuid) -> Self {
9699
Self(inner)
97100
}

0 commit comments

Comments
 (0)