Merge pull request #3 from shomitarai/master

add conversion of &str to CString in set_language method
This commit is contained in:
0/0 2022-11-17 18:53:41 -07:00 committed by GitHub
commit 520ea9d4d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
use std::ffi::c_int;
use std::ffi::{c_int, CString};
use std::marker::PhantomData;
pub enum SamplingStrategy {
@ -113,7 +113,8 @@ impl<'a> FullParams<'a> {
///
/// Defaults to "en".
pub fn set_language(&mut self, language: &'a str) {
self.fp.language = language.as_ptr() as *const _;
let c_lang = CString::new(language).expect("Language contains null byte");
self.fp.language = c_lang.into_raw() as *const _;
}
/// Set the callback for new segments.