mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Rewrite From/TryFrom conversions on generated types to avoid future orphan rule violations (#34554)
* script: Add traits to allow converting between types that are not defined in the script crate. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Rewrite all From/TryFrom implementations on generated WebIDL types to use new Convert/TryConvert traits. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
e10e989abb
commit
e0cbab2fbb
40 changed files with 439 additions and 380 deletions
|
@ -9,6 +9,7 @@ use webxr_api::{
|
|||
SelectKind, TargetRayMode,
|
||||
};
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRigidTransformInit;
|
||||
use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::{
|
||||
FakeXRButtonStateInit, FakeXRButtonType, FakeXRInputControllerMethods,
|
||||
|
@ -165,9 +166,9 @@ impl FakeXRInputControllerMethods<crate::DomTypeHolder> for FakeXRInputControlle
|
|||
}
|
||||
}
|
||||
|
||||
impl From<FakeXRButtonType> for MockButtonType {
|
||||
fn from(b: FakeXRButtonType) -> Self {
|
||||
match b {
|
||||
impl Convert<MockButtonType> for FakeXRButtonType {
|
||||
fn convert(self) -> MockButtonType {
|
||||
match self {
|
||||
FakeXRButtonType::Grip => MockButtonType::Grip,
|
||||
FakeXRButtonType::Touchpad => MockButtonType::Touchpad,
|
||||
FakeXRButtonType::Thumbstick => MockButtonType::Thumbstick,
|
||||
|
@ -182,7 +183,7 @@ pub fn init_to_mock_buttons(buttons: &[FakeXRButtonStateInit]) -> Vec<MockButton
|
|||
let supported: Vec<MockButton> = buttons
|
||||
.iter()
|
||||
.map(|b| MockButton {
|
||||
button_type: b.buttonType.into(),
|
||||
button_type: b.buttonType.convert(),
|
||||
pressed: b.pressed,
|
||||
touched: b.touched,
|
||||
pressed_value: *b.pressedValue,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue