diff --git a/src/compiler/rust/as_slice.rs b/src/compiler/rust/as_slice.rs index fc4eba16bb4..8e6657cc36a 100644 --- a/src/compiler/rust/as_slice.rs +++ b/src/compiler/rust/as_slice.rs @@ -1,6 +1,8 @@ // Copyright © 2024 Collabora, Ltd. // SPDX-License-Identifier: MIT +use std::ops::Deref; +use std::ops::DerefMut; use std::ops::Index; pub enum AttrList { @@ -26,3 +28,20 @@ pub trait AsSlice { fn as_mut_slice(&mut self) -> &mut [T]; fn attrs(&self) -> AttrList; } + +impl AsSlice for Box +where + A: AsSlice, +{ + type Attr = A::Attr; + + fn as_slice(&self) -> &[T] { + self.deref().as_slice() + } + fn as_mut_slice(&mut self) -> &mut [T] { + self.deref_mut().as_mut_slice() + } + fn attrs(&self) -> AttrList { + self.deref().attrs() + } +}