Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make functions that can be const, const #394

Merged
merged 1 commit into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Builder {
///
/// let uuid = Builder::from_bytes(bytes);
/// ```
pub fn from_bytes(b: Bytes) -> Self {
pub const fn from_bytes(b: Bytes) -> Self {
Builder(crate::Uuid::from_bytes(b))
}

Expand Down Expand Up @@ -186,7 +186,7 @@ impl Builder {
/// "00000000-0000-0000-0000-000000000000"
/// );
/// ```
pub fn nil() -> Self {
pub const fn nil() -> Self {
Builder(crate::Uuid::nil())
}

Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
//! [`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen

#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "const_fn", feature(const_fn))]
#![deny(
missing_copy_implementations,
missing_debug_implementations,
Expand Down Expand Up @@ -603,7 +602,7 @@ impl Uuid {
/// details.
///
/// * [Version Reference](http://tools.ietf.org/html/rfc4122#section-4.1.3)
pub fn get_version_num(&self) -> usize {
pub const fn get_version_num(&self) -> usize {
(self.as_bytes()[6] >> 4) as usize
}

Expand Down Expand Up @@ -930,7 +929,7 @@ impl Uuid {
/// "urn:uuid:00000000-0000-0000-0000-000000000000"
/// );
/// ```
pub fn encode_buffer() -> [u8; adapter::Urn::LENGTH] {
pub const fn encode_buffer() -> [u8; adapter::Urn::LENGTH] {
[0; adapter::Urn::LENGTH]
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl Context {
/// process.
///
/// [`Uuid`]: ../struct.Uuid.html
pub fn new(count: u16) -> Self {
pub const fn new(count: u16) -> Self {
Self {
count: atomic::AtomicUsize::new(count as usize),
}
Expand Down