pub fn try_partial_cmp(&self, other: &Self) -> Result<Option<Ordering>, ErrorKind> {
      if self.0.kind() != other.0.kind() {
         Err(ErrorKind::TypeError {
            expected: self.type_name(),
            got: other.type_name(),
         })
      } else {
         match self.0.kind() {
            ValueKind::Nil => Ok(Some(Ordering::Equal)),
            ValueKind::Boolean => {
               let a = unsafe { self.0.get_boolean_unchecked() };
               let b = unsafe { other.0.get_boolean_unchecked() };
               Ok(Some(a.cmp(&b)))
            }
            ValueKind::Number => {
               let a = unsafe { self.0.get_number_unchecked() };
               let b = unsafe { other.0.get_number_unchecked() };
               Ok(a.partial_cmp(b))
            }
            ValueKind::String => unsafe {
               let a = self.0.get_raw_string_unchecked();
               let b = other.0.get_raw_string_unchecked();
               Ok(Some(a.get().cmp(b.get())))
            },
            ValueKind::Function => Ok(None),
            ValueKind::Struct => Ok(None),
            ValueKind::List => unsafe {
               let a = self.0.get_raw_list_unchecked();
               let b = other.0.get_raw_list_unchecked();
               a.get().try_partial_cmp(b.get())
            },
            ValueKind::UserData => Ok(None),
         }
      }
   }
/// Attempts to partially compare this value with another one.
///
/// Returns an error if the types of the two values are not the same.
Attempts to partially compare this value with another one.
Returns an error if the types of the two values are not the same.
Attempts to partially compare this value with another one . Returns an error if the types of the two values are not the same .
pub fn try_partial_cmp(&self, other: &Self) -> Result<Option<Ordering>, ErrorKind> {
      if self.0.kind() != other.0.kind() {
         Err(ErrorKind::TypeError {
            expected: self.type_name(),
            got: other.type_name(),
         })
      } else {
         match self.0.kind() {
            ValueKind::Nil => Ok(Some(Ordering::Equal)),
            ValueKind::Boolean => {
               let a = unsafe { self.0.get_boolean_unchecked() };
               let b = unsafe { other.0.get_boolean_unchecked() };
               Ok(Some(a.cmp(&b)))
            }
            ValueKind::Number => {
               let a = unsafe { self.0.get_number_unchecked() };
               let b = unsafe { other.0.get_number_unchecked() };
               Ok(a.partial_cmp(b))
            }
            ValueKind::String => unsafe {
               let a = self.0.get_raw_string_unchecked();
               let b = other.0.get_raw_string_unchecked();
               Ok(Some(a.get().cmp(b.get())))
            },
            ValueKind::Function => Ok(None),
            ValueKind::Struct => Ok(None),
            ValueKind::List => unsafe {
               let a = self.0.get_raw_list_unchecked();
               let b = other.0.get_raw_list_unchecked();
               a.get().try_partial_cmp(b.get())
            },
            ValueKind::UserData => Ok(None),
         }
      }
   }
pub fn try_partial_cmp ( & self , other : & Self ) -> Result < Option < Ordering > , ErrorKind > { if self . 0 . kind ( ) != other . 0 . kind ( ) { Err ( ErrorKind :: TypeError { expected : self . type_name ( ) , got : other . type_name ( ) , } ) } else { match self . 0 . kind ( ) { ValueKind :: Nil => Ok ( Some ( Ordering :: Equal ) ) , ValueKind :: Boolean => { let a = unsafe { self . 0 . get_boolean_unchecked ( ) } ; let b = unsafe { other . 0 . get_boolean_unchecked ( ) } ; Ok ( Some ( a . cmp ( & b ) ) ) } ValueKind :: Number => { let a = unsafe { self . 0 . get_number_unchecked ( ) } ; let b = unsafe { other . 0 . get_number_unchecked ( ) } ; Ok ( a . partial_cmp ( b ) ) } ValueKind :: String => unsafe { let a = self . 0 . get_raw_string_unchecked ( ) ; let b = other . 0 . get_raw_string_unchecked ( ) ; Ok ( Some ( a . get ( ) . cmp ( b . get ( ) ) ) ) } , ValueKind :: Function => Ok ( None ) , ValueKind :: Struct => Ok ( None ) , ValueKind :: List => unsafe { let a = self . 0 . get_raw_list_unchecked ( ) ; let b = other . 0 . get_raw_list_unchecked ( ) ; a . get ( ) . try_partial_cmp ( b . get ( ) ) } , ValueKind :: UserData => Ok ( None ) , } } }
Attempts to partially compare this value with another one.
Attempts to partially compare this value with another one .
&self
other
&Self