From d77108fca6dd313b76e1efa20ec257d00a1eb30e Mon Sep 17 00:00:00 2001 From: 0/0 Date: Fri, 5 May 2023 01:33:06 +0000 Subject: [PATCH] Change token_to_str to return `&str` instead of `String` --- src/whisper_ctx.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/whisper_ctx.rs b/src/whisper_ctx.rs index 954f157..9553702 100644 --- a/src/whisper_ctx.rs +++ b/src/whisper_ctx.rs @@ -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 { + 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.