Skip to content

Commit

Permalink
Use Cow<'static, str>, following prebuilt upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Jun 23, 2024
1 parent cd31a83 commit 21994cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 6 additions & 5 deletions godot-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ mod godot_version;
#[path = ""]
mod depend_on_custom {
use super::*;
use std::borrow::Cow;

pub(crate) mod godot_exe;
pub(crate) mod godot_version;
pub(crate) mod header_gen;

pub fn load_gdextension_json(watch: &mut StopWatch) -> String {
godot_exe::load_gdextension_json(watch)
pub fn load_gdextension_json(watch: &mut StopWatch) -> Cow<'static, str> {
Cow::Owned(godot_exe::load_gdextension_json(watch))
}

pub fn write_gdextension_headers(h_path: &Path, rs_path: &Path, watch: &mut StopWatch) {
Expand Down Expand Up @@ -84,19 +85,19 @@ mod depend_on_prebuilt {
use super::*;
use crate::import::prebuilt;

pub fn load_gdextension_json(_watch: &mut StopWatch) -> &'static str {
pub fn load_gdextension_json(_watch: &mut StopWatch) -> std::borrow::Cow<'static, str> {
prebuilt::load_gdextension_json()
}

pub fn write_gdextension_headers(h_path: &Path, rs_path: &Path, watch: &mut StopWatch) {
// Note: prebuilt artifacts just return a static str.
let h_contents = prebuilt::load_gdextension_header_h();
std::fs::write(h_path, h_contents)
std::fs::write(h_path, h_contents.as_ref())
.unwrap_or_else(|e| panic!("failed to write gdextension_interface.h: {e}"));
watch.record("write_header_h");

let rs_contents = prebuilt::load_gdextension_header_rs();
std::fs::write(rs_path, rs_contents)
std::fs::write(rs_path, rs_contents.as_ref())
.unwrap_or_else(|e| panic!("failed to write gdextension_interface.rs: {e}"));
watch.record("write_header_rs");
}
Expand Down
1 change: 0 additions & 1 deletion godot-codegen/src/models/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ pub fn load_extension_api(watch: &mut godot_bindings::StopWatch) -> JsonExtensio
// #[allow]: as_ref() acts as impl AsRef<str>, but with conditional compilation

let json = godot_bindings::load_gdextension_json(watch);
#[allow(clippy::useless_asref)]
let json_str: &str = json.as_ref();

let model: JsonExtensionApi =
Expand Down

0 comments on commit 21994cb

Please sign in to comment.