Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodie committed Dec 25, 2021
1 parent c0ffee5 commit ad38b90
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion tests/borrowed.rs
Expand Up @@ -18,7 +18,7 @@ struct Bar<'a> {
#[derive(Clone)]
struct SomeCloneType {
#[allow(dead_code)]
pub foo: u32,
foo: u32,
}

#[test]
Expand All @@ -37,5 +37,6 @@ fn borrowed() {

fn test<'b, 'a: 'b>(lives_longer: &Foo<'a>, lives_less: Foo<'b>) {
drop(lives_less);
#[allow(clippy::drop_ref)]
drop(lives_longer);
}
8 changes: 4 additions & 4 deletions tests/generic_tuple_struct.rs
Expand Up @@ -11,15 +11,15 @@ struct Foo<'a, T: 'a + ToOwned + ?Sized>(Cow<'a, T>);
fn tuple_struct() {
let non_static_string: String = "foobar".to_string();

let foo = Foo(Cow::Borrowed(&non_static_string));
let thing = Foo(Cow::Borrowed(&non_static_string));

accepts_only_static(foo.into_owned());
accepts_only_static(thing.into_owned());

let non_static_vec: Vec<u8> = vec![0u8; 8];

let foo = Foo(Cow::Borrowed(&non_static_vec[..]));
let thing = Foo(Cow::Borrowed(&non_static_vec[..]));

accepts_only_static(foo.into_owned());
accepts_only_static(thing.into_owned());
}

fn accepts_only_static<T: ToOwned + 'static + ?Sized>(static_foo: Foo<'static, T>) {
Expand Down
10 changes: 5 additions & 5 deletions tests/opt_field.rs
Expand Up @@ -24,14 +24,14 @@ struct Wilder<'a> {
fn opt_cow_field() {
let s = "foobar".to_string();

let foo = Foo {
let thing = Foo {
field: Some(Cow::Borrowed(&s)),
};
assert_eq!(foo.clone().into_owned(), foo);
accepts_only_static(foo.into_owned());
assert_eq!(thing.clone().into_owned(), thing);
accepts_only_static(thing.into_owned());

let foo = Foo { field: None };
accepts_only_static(foo.into_owned());
let thing = Foo { field: None };
accepts_only_static(thing.into_owned());
}

fn accepts_only_static<T: 'static>(anything: T) {
Expand Down
4 changes: 2 additions & 2 deletions tests/tuple_struct.rs
Expand Up @@ -25,9 +25,9 @@ struct Dar<'a>(borrow::Cow<'a, str>);
fn tuple_struct() {
let non_static_string: String = "foobar".to_string();

let foo = Foo(Cow::Borrowed(&non_static_string));
let thing = Foo(Cow::Borrowed(&non_static_string));

accepts_only_static(foo.into_owned());
accepts_only_static(thing.into_owned());
}

fn accepts_only_static(static_foo: Foo<'static>) {
Expand Down

0 comments on commit ad38b90

Please sign in to comment.