proptest/arbitrary/_alloc/
borrow.rs

1//-
2// Copyright 2017, 2018 The proptest developers
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10//! Arbitrary implementations for std::borrow.
11
12use crate::std_facade::fmt;
13use crate::std_facade::{Cow, ToOwned};
14use core::borrow::Borrow;
15
16use crate::arbitrary::{any_with, Arbitrary, SMapped};
17use crate::strategy::statics::static_map;
18
19arbitrary!(
20    [A: Arbitrary + Borrow<B>, B: ToOwned<Owned = A> + fmt::Debug + ?Sized]
21    Cow<'static, B>, SMapped<A, Self>, A::Parameters;
22    args => static_map(any_with::<A>(args), Cow::Owned)
23);
24
25lift1!([Borrow<B> + 'static, B: ToOwned<Owned = A> + fmt::Debug + ?Sized]
26    Cow<'static, B>; base => static_map(base, Cow::Owned)
27);