]>
git.proxmox.com Git - rustc.git/blob - src/vendor/serde_json/src/value/partial_eq.rs
1 // Copyright 2017 Serde Developers
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6 // option. This file may not be copied, modified, or distributed
7 // except according to those terms.
11 fn eq_i64(value
: &Value
, other
: i64) -> bool
{
12 value
.as_i64().map_or(false, |i
| i
== other
)
15 fn eq_u64(value
: &Value
, other
: u64) -> bool
{
16 value
.as_u64().map_or(false, |i
| i
== other
)
19 fn eq_f64(value
: &Value
, other
: f64) -> bool
{
20 value
.as_f64().map_or(false, |i
| i
== other
)
23 fn eq_bool(value
: &Value
, other
: bool
) -> bool
{
24 value
.as_bool().map_or(false, |i
| i
== other
)
27 fn eq_str(value
: &Value
, other
: &str) -> bool
{
28 value
.as_str().map_or(false, |i
| i
== other
)
31 impl PartialEq
<str> for Value
{
32 fn eq(&self, other
: &str) -> bool
{
37 impl<'a
> PartialEq
<&'a
str> for Value
{
38 fn eq(&self, other
: &&str) -> bool
{
43 impl PartialEq
<Value
> for str {
44 fn eq(&self, other
: &Value
) -> bool
{
49 impl<'a
> PartialEq
<Value
> for &'a
str {
50 fn eq(&self, other
: &Value
) -> bool
{
55 impl PartialEq
<String
> for Value
{
56 fn eq(&self, other
: &String
) -> bool
{
57 eq_str(self, other
.as_str())
61 impl PartialEq
<Value
> for String
{
62 fn eq(&self, other
: &Value
) -> bool
{
63 eq_str(other
, self.as_str())
67 macro_rules
! partialeq_numeric
{
68 ($
($eq
:ident
[$
($ty
:ty
)*])*) => {
70 impl PartialEq
<$ty
> for Value
{
71 fn eq(&self, other
: &$ty
) -> bool
{
72 $
eq(self, *other
as _
)
76 impl PartialEq
<Value
> for $ty
{
77 fn eq(&self, other
: &Value
) -> bool
{
78 $
eq(other
, *self as _
)
82 impl<'a
> PartialEq
<$ty
> for &'a Value
{
83 fn eq(&self, other
: &$ty
) -> bool
{
84 $
eq(*self, *other
as _
)
88 impl<'a
> PartialEq
<$ty
> for &'a
mut Value
{
89 fn eq(&self, other
: &$ty
) -> bool
{
90 $
eq(*self, *other
as _
)
98 eq_i64
[i8 i16 i32 i64 isize]
99 eq_u64
[u8 u16 u32 u64 usize]