Skip to content

Commit 2e3f091

Browse files
committed
refactor: Migrate to 2024 Rust edition
1 parent 258b2e6 commit 2e3f091

23 files changed

Lines changed: 62 additions & 60 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ default-members = [
1919
[workspace.package]
2020
authors = ["The AccessKit contributors"]
2121
categories = ["gui"]
22-
edition = "2021"
22+
edition = "2024"
2323
license = "MIT OR Apache-2.0"
2424
repository = "https://github.com/AccessKit/accesskit"
2525
rust-version = "1.85"

common/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ use core::fmt;
1919
#[cfg(feature = "pyo3")]
2020
use pyo3::pyclass;
2121
#[cfg(feature = "schemars")]
22-
use schemars::{json_schema, JsonSchema, Schema, SchemaGenerator};
22+
use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema};
2323
#[cfg(feature = "serde")]
2424
use serde::{
25+
Deserialize, Serialize,
2526
de::{Deserializer, IgnoredAny, MapAccess, Visitor},
2627
ser::{SerializeMap, Serializer},
27-
Deserialize, Serialize,
2828
};
2929
#[cfg(feature = "schemars")]
3030
use serde_json::{Map as SchemaMap, Value as SchemaValue};
@@ -2590,9 +2590,9 @@ impl JsonSchema for Properties {
25902590
"Properties".into()
25912591
}
25922592

2593-
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
2593+
fn json_schema(generator: &mut SchemaGenerator) -> Schema {
25942594
let mut properties = SchemaMap::<String, SchemaValue>::new();
2595-
add_properties_to_schema!(gen, properties, {
2595+
add_properties_to_schema!(generator, properties, {
25962596
Vec<NodeId> {
25972597
Children,
25982598
Controls,

platforms/android/src/action.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// the LICENSE-APACHE file) or the MIT license (found in
44
// the LICENSE-MIT file), at your option.
55

6-
use jni::{objects::JObject, sys::jint, JNIEnv};
6+
use jni::{JNIEnv, objects::JObject, sys::jint};
77

88
use crate::util::*;
99

platforms/android/src/adapter.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ use accesskit::{
1515
};
1616
use accesskit_consumer::{FilterResult, Node, TextPosition, Tree, TreeChangeHandler};
1717
use jni::{
18+
JNIEnv,
1819
objects::JObject,
1920
sys::{jfloat, jint},
20-
JNIEnv,
2121
};
2222

2323
use crate::{
2424
action::{PlatformAction, PlatformActionInner},
2525
event::{QueuedEvent, QueuedEvents, ScrollDimension},
2626
filters::filter,
27-
node::{add_action, NodeWrapper},
27+
node::{NodeWrapper, add_action},
2828
util::*,
2929
};
3030

@@ -613,11 +613,7 @@ impl Adapter {
613613
self.set_text_selection_common(action_handler, &mut events, virtual_view_id, |node| {
614614
let current = node.text_selection_focus().unwrap_or_else(|| {
615615
let range = node.document_range();
616-
if forward {
617-
range.start()
618-
} else {
619-
range.end()
620-
}
616+
if forward { range.start() } else { range.end() }
621617
});
622618
if (forward && current.is_document_end())
623619
|| (!forward && current.is_document_start())
@@ -724,12 +720,10 @@ impl Adapter {
724720
}
725721
let focus = if forward { segment_end } else { segment_start };
726722
let anchor = if extend_selection {
727-
node.text_selection_anchor().unwrap_or({
728-
if forward {
729-
segment_start
730-
} else {
731-
segment_end
732-
}
723+
node.text_selection_anchor().unwrap_or(if forward {
724+
segment_start
725+
} else {
726+
segment_end
733727
})
734728
} else {
735729
focus

platforms/android/src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Use of this source code is governed by a BSD-style license that can be
99
// found in the LICENSE.chromium file.
1010

11-
use jni::{objects::JObject, sys::jint, JNIEnv};
11+
use jni::{JNIEnv, objects::JObject, sys::jint};
1212

1313
use crate::util::*;
1414

platforms/android/src/inject.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111

1212
use accesskit::{ActionHandler, ActivationHandler, TreeUpdate};
1313
use jni::{
14+
JNIEnv, JavaVM, NativeMethod,
1415
errors::Result,
1516
objects::{GlobalRef, JClass, JObject, WeakRef},
16-
sys::{jboolean, jfloat, jint, jlong, JNI_FALSE, JNI_TRUE},
17-
JNIEnv, JavaVM, NativeMethod,
17+
sys::{JNI_FALSE, JNI_TRUE, jboolean, jfloat, jint, jlong},
1818
};
1919
use log::debug;
2020
use std::{
2121
collections::BTreeMap,
2222
ffi::c_void,
2323
fmt::{Debug, Formatter},
2424
sync::{
25-
atomic::{AtomicI64, Ordering},
2625
Arc, Mutex, OnceLock, Weak,
26+
atomic::{AtomicI64, Ordering},
2727
},
2828
};
2929

platforms/android/src/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use accesskit::{Action, Live, Role, Toggled};
1212
use accesskit_consumer::Node;
13-
use jni::{objects::JObject, sys::jint, JNIEnv};
13+
use jni::{JNIEnv, objects::JObject, sys::jint};
1414

1515
use crate::{filters::filter, util::*};
1616

platforms/android/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// the LICENSE-MIT file), at your option.
55

66
use accesskit_consumer::{Node, NodeId};
7-
use jni::{objects::JObject, sys::jint, JNIEnv};
7+
use jni::{JNIEnv, objects::JObject, sys::jint};
88
use std::collections::HashMap;
99

1010
pub(crate) const ACTION_FOCUS: jint = 1 << 0;

platforms/atspi-common/src/adapter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// found in the LICENSE.chromium file.
1010

1111
use crate::{
12+
AdapterCallback, Event, ObjectEvent, WindowEvent,
1213
context::{ActionHandlerNoMut, ActionHandlerWrapper, AppContext, Context},
1314
filters::filter,
1415
node::{NodeIdOrRoot, NodeWrapper, PlatformNode, PlatformRoot},
1516
util::WindowBounds,
16-
AdapterCallback, Event, ObjectEvent, WindowEvent,
1717
};
1818
use accesskit::{ActionHandler, Role, TreeUpdate};
1919
use accesskit_consumer::{FilterResult, Node, NodeId, Tree, TreeChangeHandler, TreeState};
@@ -22,8 +22,8 @@ use std::fmt::{Debug, Formatter};
2222
use std::{
2323
collections::HashSet,
2424
sync::{
25-
atomic::{AtomicUsize, Ordering},
2625
Arc, RwLock,
26+
atomic::{AtomicUsize, Ordering},
2727
},
2828
};
2929

platforms/atspi-common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub use atspi_common::{
2323
};
2424

2525
pub use action::*;
26-
pub use adapter::{next_adapter_id, Adapter};
26+
pub use adapter::{Adapter, next_adapter_id};
2727
pub use callback::AdapterCallback;
2828
pub use context::{ActionHandlerNoMut, ActionHandlerWrapper, AppContext};
2929
pub use error::*;

0 commit comments

Comments
 (0)