Skip to content

Commit

Permalink
fix: make version return a static string
Browse files Browse the repository at this point in the history
moved .to_string() into each glue code
  • Loading branch information
alemidev committed Oct 12, 2024
1 parent 306a687 commit 6dedb5f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ffi/java/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use jni_toolbox::jni;
#[allow(non_snake_case)]
#[jni(package = "mp.code", class = "Extensions")]
fn version() -> String {
crate::version()
crate::version().to_string()
}

/// Calculate the XXH3 hash for a given String.
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/js/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ pub fn js_hash(data: String) -> i64 {
/// Get the current version of the client
#[napi(js_name = "version")]
pub fn js_version() -> String {
crate::version()
crate::version().to_string()
}
2 changes: 1 addition & 1 deletion src/ffi/lua/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn entrypoint(lua: &Lua) -> LuaResult<LuaTable> {

exports.set(
"version",
lua.create_function(|_, ()| Ok(crate::version()))?,
lua.create_function(|_, ()| Ok(crate::version().to_string()))?,
)?;

// runtime
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Driver {

#[pyfunction]
fn version() -> String {
crate::version()
crate::version().to_string()
}

#[pyfunction]
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ pub mod ffi;
pub(crate) mod network;

/// Get the current version of the client
pub fn version() -> String {
env!("CARGO_PKG_VERSION").to_owned()
pub fn version() -> &'static str {
env!("CARGO_PKG_VERSION")
}

0 comments on commit 6dedb5f

Please sign in to comment.