From 611c5ebce5b59dfc9f5ef81b7c637317f572be59 Mon Sep 17 00:00:00 2001 From: Mel Henning Date: Wed, 10 Sep 2025 21:47:24 -0400 Subject: [PATCH] compiler/rust: impl AsSlice for Box MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acked-by: Faith Ekstrand Reviewed-by: Seán de Búrca Part-of: --- src/compiler/rust/as_slice.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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() + } +}