Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions typify-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ pub(crate) enum Name {
impl Name {
pub fn into_option(self) -> Option<String> {
match self {
Name::Required(s) | Name::Suggested(s) => Some(s),
Name::Unknown => None,
Self::Required(s) | Self::Suggested(s) => Some(s),
Self::Unknown => None,
}
}

pub fn append(&self, s: &str) -> Self {
match self {
Name::Required(prefix) | Name::Suggested(prefix) => {
Self::Required(prefix) | Self::Suggested(prefix) => {
Self::Suggested(format!("{}_{}", prefix, s))
}
Name::Unknown => Name::Unknown,
Self::Unknown => Self::Unknown,
}
}
}
Expand Down
45 changes: 23 additions & 22 deletions typify-impl/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,29 +1131,30 @@ trait Roughly {
impl Roughly for schemars::schema::Schema {
fn roughly(&self, other: &Self) -> bool {
match (self, other) {
(Schema::Bool(a), Schema::Bool(b)) => a == b,
(Schema::Bool(false), _) | (_, Schema::Bool(false)) => false,

(Schema::Bool(true), Schema::Object(other))
| (Schema::Object(other), Schema::Bool(true)) => matches!(
other,
SchemaObject {
metadata: _,
instance_type: None,
format: None,
enum_values: None,
const_value: None,
subschemas: None,
number: None,
string: None,
array: None,
object: None,
reference: None,
extensions: _,
}
),
(Self::Bool(a), Self::Bool(b)) => a == b,
(Self::Bool(false), _) | (_, Self::Bool(false)) => false,

(Self::Bool(true), Self::Object(other)) | (Self::Object(other), Self::Bool(true)) => {
matches!(
other,
SchemaObject {
metadata: _,
instance_type: None,
format: None,
enum_values: None,
const_value: None,
subschemas: None,
number: None,
string: None,
array: None,
object: None,
reference: None,
extensions: _,
}
)
}

(Schema::Object(a), Schema::Object(b)) => {
(Self::Object(a), Self::Object(b)) => {
a.instance_type == b.instance_type
&& a.format == b.format
&& a.enum_values == b.enum_values
Expand Down
10 changes: 5 additions & 5 deletions typify-impl/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ impl SynCompare for Variant {
impl SynCompare for Fields {
fn syn_cmp(&self, other: &Self, _: bool) -> Result<(), String> {
match (self, other) {
(Fields::Named(a), Fields::Named(b)) => a.syn_cmp(b, false),
(Fields::Unnamed(a), Fields::Unnamed(b)) => a.syn_cmp(b, false),
(Fields::Unit, Fields::Unit) => Ok(()),
(Self::Named(a), Self::Named(b)) => a.syn_cmp(b, false),
(Self::Unnamed(a), Self::Unnamed(b)) => a.syn_cmp(b, false),
(Self::Unit, Self::Unit) => Ok(()),
_ => Err("mismatched field types".to_string()),
}
}
Expand Down Expand Up @@ -314,8 +314,8 @@ impl SynCompare for Field {
impl SynCompare for Type {
fn syn_cmp(&self, other: &Self, _: bool) -> Result<(), String> {
match (self, other) {
(Type::Tuple(a), Type::Tuple(b)) => a.syn_cmp(b, false),
(Type::Path(a), Type::Path(b)) => a.syn_cmp(b, false),
(Self::Tuple(a), Self::Tuple(b)) => a.syn_cmp(b, false),
(Self::Path(a), Self::Path(b)) => a.syn_cmp(b, false),
_ => Err(format!(
"unexpected or mismatched type pair: {:?} {:?}",
self, other
Expand Down
8 changes: 4 additions & 4 deletions typify-impl/src/type_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ impl From<TypeEntryDetails> for TypeEntry {

impl TypeEntry {
pub(crate) fn new_native<S: ToString>(type_name: S, impls: &[TypeSpaceImpl]) -> Self {
TypeEntry {
Self {
details: TypeEntryDetails::Native(TypeEntryNative {
type_name: type_name.to_string(),
impls: impls.to_vec(),
Expand All @@ -556,7 +556,7 @@ impl TypeEntry {
}
}
pub(crate) fn new_native_params<S: ToString>(type_name: S, params: &[TypeId]) -> Self {
TypeEntry {
Self {
details: TypeEntryDetails::Native(TypeEntryNative {
type_name: type_name.to_string(),
impls: Default::default(),
Expand All @@ -566,7 +566,7 @@ impl TypeEntry {
}
}
pub(crate) fn new_boolean() -> Self {
TypeEntry {
Self {
details: TypeEntryDetails::Boolean,
extra_derives: Default::default(),
}
Expand All @@ -575,7 +575,7 @@ impl TypeEntry {
TypeEntryDetails::Integer(type_name.to_string()).into()
}
pub(crate) fn new_float<S: ToString>(type_name: S) -> Self {
TypeEntry {
Self {
details: TypeEntryDetails::Float(type_name.to_string()),
extra_derives: Default::default(),
}
Expand Down