Skip to content

Commit

Permalink
Change _ref_mut to _mut.
Browse files Browse the repository at this point in the history
  • Loading branch information
schungx committed Jul 29, 2024
1 parent a6e1ba1 commit b7abf44
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/bin/rhai-dbg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn print_current_source(
.global_runtime_state_mut()
.debugger_mut()
.state_mut()
.as_immutable_string_ref_mut()
.as_immutable_string_mut()
.unwrap();
let src = source.unwrap_or("");
if src != current_source {
Expand Down
18 changes: 9 additions & 9 deletions src/func/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt
PlusAssign => Some((
|_ctx, args| {
let (first, second) = args.split_first_mut().unwrap();
let x = &mut *first.as_immutable_string_ref_mut().unwrap();
let x = &mut *first.as_immutable_string_mut().unwrap();
let y = &*second[0].as_immutable_string_ref().unwrap();

#[cfg(not(feature = "unchecked"))]
Expand All @@ -810,7 +810,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt
MinusAssign => Some((
|_, args| {
let (first, second) = args.split_first_mut().unwrap();
let x = &mut *first.as_immutable_string_ref_mut().unwrap();
let x = &mut *first.as_immutable_string_mut().unwrap();
let y = &*second[0].as_immutable_string_ref().unwrap();
*x -= y;
Ok(Dynamic::UNIT)
Expand Down Expand Up @@ -843,7 +843,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt
)?;
}

let array = &mut *args[0].as_array_ref_mut().unwrap();
let array = &mut *args[0].as_array_mut().unwrap();

append(array, x);

Expand All @@ -864,7 +864,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt
PlusAssign => Some((
|_ctx, args| {
let blob2 = args[1].take().into_blob().unwrap();
let blob1 = &mut *args[0].as_blob_ref_mut().unwrap();
let blob1 = &mut *args[0].as_blob_mut().unwrap();

#[cfg(not(feature = "unchecked"))]
_ctx.unwrap()
Expand Down Expand Up @@ -954,7 +954,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt
|_ctx, args| {
let mut buf = [0_u8; 4];
let ch = &*args[1].as_char().unwrap().encode_utf8(&mut buf);
let mut x = args[0].as_immutable_string_ref_mut().unwrap();
let mut x = args[0].as_immutable_string_mut().unwrap();

#[cfg(not(feature = "unchecked"))]
_ctx.unwrap()
Expand Down Expand Up @@ -1015,7 +1015,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt
|_ctx, args| {
{
let x = args[1].take();
let array = &mut *args[0].as_array_ref_mut().unwrap();
let array = &mut *args[0].as_array_mut().unwrap();
push(array, x);
}

Expand Down Expand Up @@ -1045,7 +1045,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt
PlusAssign => Some((
|_ctx, args| {
let x = args[1].as_int().unwrap();
let blob = &mut *args[0].as_blob_ref_mut().unwrap();
let blob = &mut *args[0].as_blob_mut().unwrap();

#[cfg(not(feature = "unchecked"))]
_ctx.unwrap()
Expand All @@ -1071,7 +1071,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt
PlusAssign => Some((
|_ctx, args| {
let x = args[1].as_char().unwrap();
let blob = &mut *args[0].as_blob_ref_mut().unwrap();
let blob = &mut *args[0].as_blob_mut().unwrap();

#[cfg(not(feature = "unchecked"))]
_ctx.unwrap()
Expand All @@ -1097,7 +1097,7 @@ pub fn get_builtin_op_assignment_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Opt
PlusAssign => Some((
|_ctx, args| {
let (first, second) = args.split_first_mut().unwrap();
let blob = &mut *first.as_blob_ref_mut().unwrap();
let blob = &mut *first.as_blob_mut().unwrap();
let s = &*second[0].as_immutable_string_ref().unwrap();

if s.is_empty() {
Expand Down
8 changes: 4 additions & 4 deletions src/types/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@ impl Dynamic {
///
/// These normally shouldn't occur since most operations in Rhai are single-threaded.
#[inline]
pub fn as_immutable_string_ref_mut(
pub fn as_immutable_string_mut(
&mut self,
) -> Result<impl DerefMut<Target = ImmutableString> + '_, &'static str> {
let type_name = self.type_name();
Expand Down Expand Up @@ -2590,7 +2590,7 @@ impl Dynamic {
/// These normally shouldn't occur since most operations in Rhai are single-threaded.
#[cfg(not(feature = "no_index"))]
#[inline(always)]
pub fn as_array_ref_mut(&mut self) -> Result<impl DerefMut<Target = Array> + '_, &'static str> {
pub fn as_array_mut(&mut self) -> Result<impl DerefMut<Target = Array> + '_, &'static str> {
let type_name = self.type_name();
self.write_lock::<Array>().ok_or(type_name)
}
Expand Down Expand Up @@ -2633,7 +2633,7 @@ impl Dynamic {
/// These normally shouldn't occur since most operations in Rhai are single-threaded.
#[cfg(not(feature = "no_index"))]
#[inline(always)]
pub fn as_blob_ref_mut(&mut self) -> Result<impl DerefMut<Target = Blob> + '_, &'static str> {
pub fn as_blob_mut(&mut self) -> Result<impl DerefMut<Target = Blob> + '_, &'static str> {
let type_name = self.type_name();
self.write_lock::<Blob>().ok_or(type_name)
}
Expand Down Expand Up @@ -2676,7 +2676,7 @@ impl Dynamic {
/// These normally shouldn't occur since most operations in Rhai are single-threaded.
#[cfg(not(feature = "no_object"))]
#[inline(always)]
pub fn as_map_ref_mut(&mut self) -> Result<impl DerefMut<Target = Map> + '_, &'static str> {
pub fn as_map_mut(&mut self) -> Result<impl DerefMut<Target = Map> + '_, &'static str> {
let type_name = self.type_name();
self.write_lock::<Map>().ok_or(type_name)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/debugging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn test_debugger_state() {
println!("Current state = {}", context.global_runtime_state().debugger().state());

// Modify state
let mut state = context.global_runtime_state_mut().debugger_mut().state_mut().as_map_ref_mut().unwrap();
let mut state = context.global_runtime_state_mut().debugger_mut().state_mut().as_map_mut().unwrap();
let hello = state.get("hello").unwrap().as_int().unwrap();
state.insert("hello".into(), (hello + 1).into());
state.insert("foo".into(), true.into());
Expand Down

0 comments on commit b7abf44

Please sign in to comment.