Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change _ref_mut to _mut. #905

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -11,7 +11,7 @@
fn test_debugging() {
let mut engine = Engine::new();

engine.register_debugger(|_, dbg| dbg, |_, _, _, _, _| Ok(rhai::debugger::DebuggerCommand::Continue));

Check warning on line 14 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_module,serde,metadata,internals,debugging, st...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 14 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_optimize,serde,metadata,internals,debugging, ...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 14 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_position,serde,metadata,internals,debugging, ...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 14 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,debugging, stable, false)

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

#[cfg(not(feature = "no_function"))]
#[cfg(not(feature = "no_index"))]
Expand Down Expand Up @@ -43,7 +43,7 @@
fn test_debugger_state() {
let mut engine = Engine::new();

engine.register_debugger(

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_module,serde,metadata,internals,debugging, st...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_index,serde,metadata,internals,debugging, sta...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,only_i64,serde,metadata,internals,debugging, sta...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_custom_syntax,serde,metadata,internals,debugg...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_time,serde,metadata,internals,debugging, stab...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_optimize,serde,metadata,internals,debugging, ...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,sync,serde,metadata,internals,debugging, stable,...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_float,serde,metadata,internals,debugging, sta...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,f32_float,serde,metadata,internals,debugging, st...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_position,serde,metadata,internals,debugging, ...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --tests --features testing-environ,only_i32,serde,metadata,internals,debugg...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,debugging, stable, false)

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,unchecked,serde,metadata,internals,debugging, st...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.

Check warning on line 46 in tests/debugging.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,decimal,serde,metadata,internals,debugging, stab...

use of deprecated method `rhai::api::events::<impl rhai::Engine>::register_debugger`: This API is NOT deprecated, but it is considered volatile and may change in the future.
|_, mut debugger| {
// Say, use an object map for the debugger state
let mut state = Map::new();
Expand All @@ -58,7 +58,7 @@
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
Loading