Skip to content

Commit cd5f2cc

Browse files
committed
Add extern_spec for PartialEq::eq on Option, Result and Box
1 parent 82a7840 commit cd5f2cc

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

std.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ fn _extern_spec_box_new<T>(x: T) -> Box<T> where T: thrust_models::Model {
250250
Box::new(x)
251251
}
252252

253+
#[thrust::extern_spec_fn]
254+
#[thrust::requires(true)]
255+
#[thrust::ensures(result == (x == y))]
256+
fn _extern_spec_box_partialeq_eq<T>(x: &Box<T>, y: &Box<T>) -> bool where T: thrust_models::Model + PartialEq {
257+
<Box<T> as PartialEq>::eq(x, y)
258+
}
259+
253260
#[thrust::extern_spec_fn]
254261
#[thrust::requires(true)]
255262
#[thrust::ensures(*x == ^y && *y == ^x)]
@@ -264,6 +271,13 @@ fn _extern_spec_std_mem_replace<T>(dest: &mut T, src: T) -> T where T: thrust_mo
264271
std::mem::replace(dest, src)
265272
}
266273

274+
#[thrust::extern_spec_fn]
275+
#[thrust::requires(true)]
276+
#[thrust::ensures(result == (x == y))]
277+
fn _extern_spec_option_partialeq_eq<T>(x: &Option<T>, y: &Option<T>) -> bool where T: thrust_models::Model + PartialEq {
278+
<Option<T> as PartialEq>::eq(x, y)
279+
}
280+
267281
#[thrust::extern_spec_fn]
268282
#[thrust::requires(opt != std::option::Option::<T0>::None())]
269283
#[thrust::ensures(std::option::Option::<T0>::Some(result) == opt)]
@@ -353,6 +367,15 @@ fn _extern_spec_option_as_mut<T>(opt: &mut Option<T>) -> Option<&mut T> where T:
353367
Option::as_mut(opt)
354368
}
355369

370+
#[thrust::extern_spec_fn]
371+
#[thrust::requires(true)]
372+
#[thrust::ensures(result == (x == y))]
373+
fn _extern_spec_result_partialeq_eq<T, E>(x: &Result<T, E>, y: &Result<T, E>) -> bool
374+
where T: thrust_models::Model + PartialEq, E: thrust_models::Model + PartialEq
375+
{
376+
<Result<T, E> as PartialEq>::eq(x, y)
377+
}
378+
356379
#[thrust::extern_spec_fn]
357380
#[thrust::requires(exists x:T0. res == std::result::Result::<T0, T1>::Ok(x))]
358381
#[thrust::ensures(std::result::Result::<T0, T1>::Ok(result) == res)]

0 commit comments

Comments
 (0)