Skip to content

Commit

Permalink
Add deprecation notice to non-array functions
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterSmuts committed Sep 22, 2023
1 parent 280dcf1 commit 77592a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/base32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl fmt::Display for EncodeError {
}

/// Encode a u128 value to a given buffer. The provided buffer should be at least `ULID_LEN` long.
#[deprecated(
since = "1.2.0",
note = "Use the infallible `encode_to_array` instead."
)]
pub fn encode_to(mut value: u128, buffer: &mut [u8]) -> Result<usize, EncodeError> {
// NOTE: This function can't be made const because mut refs aren't allowed for some reason

Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ impl Ulid {
///
/// assert_eq!(new_text, text);
/// ```
#[deprecated(since = "1.2.0", note = "Use the infallible `array_to_str` instead.")]
pub fn to_str<'buf>(&self, buf: &'buf mut [u8]) -> Result<&'buf mut str, EncodeError> {
#[allow(deprecated)]
let len = base32::encode_to(self.0, buf)?;
Ok(unsafe { core::str::from_utf8_unchecked_mut(&mut buf[..len]) })
}
Expand Down

0 comments on commit 77592a0

Please sign in to comment.