Change token_to_str to return &str instead of String
This commit is contained in:
parent
a7caf1b96a
commit
d77108fca6
1 changed files with 3 additions and 3 deletions
|
|
@ -306,14 +306,14 @@ impl WhisperContext {
|
|||
/// * token_id: ID of the token.
|
||||
///
|
||||
/// # Returns
|
||||
/// Ok(String) on success, Err(WhisperError) on failure.
|
||||
/// Ok(&str) on success, Err(WhisperError) on failure.
|
||||
///
|
||||
/// # C++ equivalent
|
||||
/// `const char * whisper_token_to_str(struct whisper_context * ctx, whisper_token token)`
|
||||
pub fn token_to_str(&self, token_id: WhisperToken) -> Result<String, WhisperError> {
|
||||
pub fn token_to_str(&self, token_id: WhisperToken) -> Result<&str, WhisperError> {
|
||||
let c_str = self.token_to_cstr(token_id)?;
|
||||
let r_str = c_str.to_str()?;
|
||||
Ok(r_str.to_string())
|
||||
Ok(r_str)
|
||||
}
|
||||
|
||||
/// Convert a token ID to a &CStr.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue