Sort funcs (#91)

This commit is contained in:
Mike Voronov
2021-06-01 19:27:21 +03:00
committed by GitHub
parent b2827a73ab
commit 17eedfd525
7 changed files with 73 additions and 46 deletions

View File

@ -17,13 +17,32 @@
use serde::Serialize;
use serde::Deserialize;
#[derive(PartialEq, Eq, Debug, Clone, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct FunctionSignature {
pub name: String,
pub arguments: Vec<(String, String)>,
pub output_types: Vec<String>,
}
use std::cmp::Ordering;
impl PartialOrd for FunctionSignature {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for FunctionSignature {
fn cmp(&self, other: &Self) -> Ordering {
if self.name < other.name {
Ordering::Less
} else if self == other {
Ordering::Equal
} else {
Ordering::Greater
}
}
}
#[derive(PartialEq, Eq, Debug, Clone, Hash, Serialize, Deserialize)]
pub struct RecordField {
pub name: String,