From b2cb752c82581e4f9c8200660be32f8a17c56329 Mon Sep 17 00:00:00 2001 From: cksac Date: Fri, 9 Feb 2024 09:05:05 +0800 Subject: [PATCH] add cow --- fake/src/impls/std/container.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fake/src/impls/std/container.rs b/fake/src/impls/std/container.rs index f18151e..b87fa7e 100644 --- a/fake/src/impls/std/container.rs +++ b/fake/src/impls/std/container.rs @@ -1,5 +1,6 @@ use crate::Dummy; use rand::Rng; +use std::borrow::Cow; use std::cell::{Cell, RefCell}; use std::ops::Deref; use std::pin::Pin; @@ -36,3 +37,12 @@ where Pin::new(T::dummy_with_rng(config, rng)) } } + +impl<'a, T, U> Dummy for Cow<'a, T> +where + T: Dummy + Clone, +{ + fn dummy_with_rng(config: &U, rng: &mut R) -> Self { + Cow::Owned(T::dummy_with_rng(config, rng)) + } +}