From e6687c5fa8337a9cb78cc811960de520d1dbe5cf Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Tue, 5 May 2020 10:42:23 +0000 Subject: [PATCH] style: Improve handling of copying arrays in layout/style/ and servo/. Differential Revision: https://phabricator.services.mozilla.com/D72351 --- .../style/gecko_bindings/sugar/ns_t_array.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/style/gecko_bindings/sugar/ns_t_array.rs b/components/style/gecko_bindings/sugar/ns_t_array.rs index e3d4e5b86bd..04ba326c615 100644 --- a/components/style/gecko_bindings/sugar/ns_t_array.rs +++ b/components/style/gecko_bindings/sugar/ns_t_array.rs @@ -5,7 +5,7 @@ //! Rust helpers for Gecko's nsTArray. use crate::gecko_bindings::bindings; -use crate::gecko_bindings::structs::{nsTArray, nsTArrayHeader}; +use crate::gecko_bindings::structs::{nsTArray, nsTArrayHeader, CopyableTArray}; use std::mem; use std::ops::{Deref, DerefMut}; use std::slice; @@ -128,3 +128,16 @@ impl nsTArray { self.iter_mut().zip(iter).for_each(|(r, v)| *r = v); } } + +impl Deref for CopyableTArray { + type Target = nsTArray; + fn deref(&self) -> &Self::Target { + &self._base + } +} + +impl DerefMut for CopyableTArray { + fn deref_mut(&mut self) -> &mut nsTArray { + &mut self._base + } +}