1
0

feat: update bmap-rs

This commit is contained in:
2026-02-18 22:44:10 +08:00
parent cf0966e6d3
commit 9c4c4a7fa4
3 changed files with 82 additions and 67 deletions

View File

@@ -67,9 +67,10 @@ pub unsafe fn from_native_string_array(ptr: PCKSTRING) -> Result<Vec<String>> {
Ok(rv)
}
pub unsafe fn to_native_string_array<T>(words: &[T]) -> Result<BMStringArray>
pub unsafe fn to_native_string_array<I, T>(words: I) -> Result<BMStringArray>
where
T: Into<Vec<u8>> + Copy,
I: Iterator<Item = T>,
T: Into<Vec<u8>>,
{
BMStringArray::new(words)
}
@@ -80,14 +81,14 @@ pub struct BMStringArray {
}
impl BMStringArray {
fn new<T>(words: &[T]) -> Result<Self>
fn new<I, T>(words: I) -> Result<Self>
where
T: Into<Vec<u8>> + Copy,
I: Iterator<Item = T>,
T: Into<Vec<u8>>,
{
// Build array items
let array_items = words
.iter()
.map(|word| CString::new(*word))
.map(|word| CString::new(word))
.collect::<std::result::Result<Vec<CString>, std::ffi::NulError>>()?;
// Build array body.
// In theory, move operation will not affect data allocated on heap.