Skip to content

Commit af9eff7

Browse files
committed
rm insert binding
1 parent 9a8a943 commit af9eff7

File tree

2 files changed

+2
-47
lines changed
  • assets/tests/insert
  • crates/bevy_mod_scripting_functions/src

2 files changed

+2
-47
lines changed

assets/tests/insert/vec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local res_type = world.get_type_by_name("TestResourceWithVariousFields")
22
local res = world.get_resource(res_type)
33

4-
res.vec_usize:insert(2, 42)
4+
res.vec_usize[2] = 42
55

6-
assert(res.vec_usize[2] == 42, "insert did not work")
6+
assert(res.vec_usize[2] == 42, "insert did not work")

crates/bevy_mod_scripting_functions/src/core.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -655,51 +655,6 @@ impl ReflectReference {
655655
ReflectReference::into_script_ref(reference, world)
656656
}
657657

658-
/// Inserts the value into the reference at the specified index, if the reference is an appropriate container type.
659-
///
660-
/// Arguments:
661-
/// * `ctxt`: The function call context.
662-
/// * `reference`: The reference to insert the value into.
663-
/// * `key`: The index to insert the value at.
664-
/// * `value`: The value to insert.
665-
/// Returns:
666-
/// * `result`: Nothing if the value was inserted successfully.
667-
fn insert(
668-
ctxt: FunctionCallContext,
669-
reference: ReflectReference,
670-
key: ScriptValue,
671-
value: ScriptValue,
672-
) -> Result<(), InteropError> {
673-
profiling::function_scope!("insert");
674-
let world = ctxt.world()?;
675-
let key_type_id = reference.key_type_id(world.clone())?.ok_or_else(|| {
676-
InteropError::unsupported_operation(
677-
reference.tail_type_id(world.clone()).unwrap_or_default(),
678-
Some(Box::new(key.clone())),
679-
"Could not get key type id. Are you trying to insert elements into a type that's not a map?".to_owned(),
680-
)
681-
})?;
682-
683-
let mut key = <Box<dyn PartialReflect>>::from_script_ref(key_type_id, key, world.clone())?;
684-
685-
if ctxt.convert_to_0_indexed() {
686-
key.convert_to_0_indexed_key();
687-
}
688-
689-
let value_type_id = reference.element_type_id(world.clone())?.ok_or_else(|| {
690-
InteropError::unsupported_operation(
691-
reference.tail_type_id(world.clone()).unwrap_or_default(),
692-
Some(Box::new(value.clone())),
693-
"Could not get element type id. Are you trying to insert elements into a type that's not a map?".to_owned(),
694-
)
695-
})?;
696-
697-
let value =
698-
<Box<dyn PartialReflect>>::from_script_ref(value_type_id, value, world.clone())?;
699-
700-
reference.with_reflect_mut(world, |s| s.try_insert_boxed(key, value))?
701-
}
702-
703658
/// Clears the container, if the reference is an appropriate container type.
704659
/// Arguments:
705660
/// * `ctxt`: The function call context.

0 commit comments

Comments
 (0)