Skip to content

Make as_ptr and as_mut_ptr on ArrayString public #260

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

Merged
merged 2 commits into from
Mar 7, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Recent Changes (arrayvec)
=========================

## Unreleased
- Add `as_ptr` and `as_mut_ptr` to `ArrayString` by @YuhanLiin

## 0.7.4

- Add feature zeroize to support the `Zeroize` trait by @elichai
Expand Down
6 changes: 4 additions & 2 deletions src/array_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,13 @@ impl<const CAP: usize> ArrayString<CAP>
self
}

fn as_ptr(&self) -> *const u8 {
/// Return a raw pointer to the string's buffer.
pub fn as_ptr(&self) -> *const u8 {
self.xs.as_ptr() as *const u8
}

fn as_mut_ptr(&mut self) -> *mut u8 {
/// Return a raw mutable pointer to the string's buffer.
pub fn as_mut_ptr(&mut self) -> *mut u8 {
self.xs.as_mut_ptr() as *mut u8
}
}
Expand Down