Skip to content

Commit 5c21292

Browse files
committed
chore: fix compilation issue
1 parent 2796c83 commit 5c21292

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

crates/bevy_mod_scripting_functions/src/core.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Contains functions defined by the [`bevy_mod_scripting_core`] crate
22
3-
use std::collections::HashMap;
3+
use std::{collections::HashMap, ops::Deref};
44

55
use bevy::prelude::*;
66
use bevy_mod_scripting_core::{
@@ -789,7 +789,7 @@ impl ReflectReference {
789789
let functions = world
790790
.get_functions_on_type(type_id)
791791
.into_iter()
792-
.map(|(_, v)| Val::new(v.info))
792+
.map(|(_, v)| Val::new(v.info.deref().clone()))
793793
.collect::<Vec<_>>();
794794
// convert to info
795795
Ok(functions)

crates/ladfile_builder/src/lib.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,17 @@ impl<'t> LadFileBuilder<'t> {
319319
/// ```
320320
///
321321
/// And then removes them from the original block, instead putting it in each argument / return docstring
322-
pub fn add_function_info(&mut self, function_info: FunctionInfo) -> &mut Self {
322+
pub fn add_function_info(&mut self, function_info: &FunctionInfo) -> &mut Self {
323323
let default_docstring = Cow::Owned("".into());
324324
let (main_docstring, arg_docstrings, return_docstring) =
325325
Self::split_docstring(function_info.docs.as_ref().unwrap_or(&default_docstring));
326326

327-
let function_id = self.lad_function_id_from_info(&function_info);
327+
let function_id = self.lad_function_id_from_info(function_info);
328328
let lad_function = LadFunction {
329-
identifier: function_info.name,
329+
identifier: function_info.name.clone(),
330330
arguments: function_info
331331
.arg_info
332+
.clone()
332333
.into_iter()
333334
.map(|arg| {
334335
let kind = match &arg.type_info {
@@ -351,6 +352,7 @@ impl<'t> LadFileBuilder<'t> {
351352
kind: function_info
352353
.return_info
353354
.type_info
355+
.clone()
354356
.map(|info| self.lad_type_kind_from_through_type(&info))
355357
.unwrap_or_else(|| {
356358
LadTypeKind::Unknown(
@@ -1080,9 +1082,9 @@ mod test {
10801082
let mut lad_file = LadFileBuilder::new(&type_registry)
10811083
.set_description("## Hello gentlemen\n I am markdown file.\n - hello\n - world")
10821084
.set_sorted(true)
1083-
.add_function_info(function_info)
1084-
.add_function_info(global_function_info)
1085-
.add_function_info(function_with_complex_args_info)
1085+
.add_function_info(&function_info)
1086+
.add_function_info(&global_function_info)
1087+
.add_function_info(&function_with_complex_args_info)
10861088
.add_type::<StructType<usize>>()
10871089
.add_type::<UnitType>()
10881090
.add_type::<TupleStructType>()

crates/ladfile_builder/src/plugin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn generate_lad_file(
9696
);
9797

9898
for (_, function) in function_registry.iter_namespace(World::into_namespace()) {
99-
builder.add_function_info(function.info.clone());
99+
builder.add_function_info(&function.info);
100100
}
101101

102102
builder.set_insignificance(
@@ -131,13 +131,13 @@ pub fn generate_lad_file(
131131
for (_, function) in
132132
function_registry.iter_namespace(Namespace::OnType(type_info.type_id()))
133133
{
134-
builder.add_function_info(function.info.clone());
134+
builder.add_function_info(&function.info);
135135
}
136136
}
137137

138138
// find functions on the global namespace
139139
for (_, function) in function_registry.iter_namespace(Namespace::Global) {
140-
builder.add_function_info(function.info.clone());
140+
builder.add_function_info(&function.info);
141141
}
142142

143143
// find global instances

crates/languages/bevy_mod_scripting_rhai/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ impl Default for RhaiScriptingPlugin {
122122
let name = key.name.clone();
123123
if ReservedKeyword::is_reserved_keyword(&name) {
124124
let new_name = format!("{}_", name);
125-
let mut function = function.clone();
126-
function.info.name = new_name.clone().into();
127125
re_insertions.push((key.namespace, new_name, function.clone()));
128126
}
129127
}

0 commit comments

Comments
 (0)