add const uuid::from_uuid_bytes

This commit is contained in:
MOKEYISH 2018-05-05 00:25:39 +08:00
parent baa0389dc8
commit 096fc74faa
3 changed files with 9 additions and 0 deletions

1
.cargo/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/config

View File

@ -33,6 +33,7 @@ serde_test = "1.0.19"
[features]
default = ["std"]
nightly = []
std = []
use_std = ["std"] # Compatibility shim for 0.5 and earlier
v1 = []

View File

@ -111,6 +111,7 @@
)]
#![deny(warnings)]
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(const_fn)]
#[macro_use]
extern crate cfg_if;
@ -714,10 +715,16 @@ impl Uuid {
///
/// let uuid = Uuid::from_uuid_bytes(bytes);
/// ```
#[cfg(not(feature = "nightly"))]
pub fn from_uuid_bytes(b: UuidBytes) -> Uuid {
Uuid { bytes: b }
}
#[cfg(feature = "nightly")]
pub const fn from_uuid_bytes(b: UuidBytes) -> Uuid {
Uuid { bytes: b }
}
/// Creates a v4 Uuid from random bytes (e.g. bytes supplied from `Rand` crate)
///
/// # Examples