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
2 changes: 1 addition & 1 deletion cargo-typify/tests/outputs/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub enum FruitOrVeg {
Fruit(Fruit),
}
impl ::std::convert::From<&Self> for FruitOrVeg {
fn from(value: &FruitOrVeg) -> Self {
fn from(value: &Self) -> Self {
value.clone()
}
}
Expand Down
2 changes: 1 addition & 1 deletion cargo-typify/tests/outputs/custom_btree_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub enum FruitOrVeg {
Fruit(Fruit),
}
impl ::std::convert::From<&Self> for FruitOrVeg {
fn from(value: &FruitOrVeg) -> Self {
fn from(value: &Self) -> Self {
value.clone()
}
}
Expand Down
2 changes: 1 addition & 1 deletion cargo-typify/tests/outputs/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub enum FruitOrVeg {
Fruit(Fruit),
}
impl ::std::convert::From<&Self> for FruitOrVeg {
fn from(value: &FruitOrVeg) -> Self {
fn from(value: &Self) -> Self {
value.clone()
}
}
Expand Down
2 changes: 1 addition & 1 deletion cargo-typify/tests/outputs/multi_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub enum FruitOrVeg {
Fruit(Fruit),
}
impl ::std::convert::From<&Self> for FruitOrVeg {
fn from(value: &FruitOrVeg) -> Self {
fn from(value: &Self) -> Self {
value.clone()
}
}
Expand Down
2 changes: 1 addition & 1 deletion cargo-typify/tests/outputs/no-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub enum FruitOrVeg {
Fruit(Fruit),
}
impl ::std::convert::From<&Self> for FruitOrVeg {
fn from(value: &FruitOrVeg) -> Self {
fn from(value: &Self) -> Self {
value.clone()
}
}
Expand Down
4 changes: 2 additions & 2 deletions typify-impl/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ mod tests {
}

impl ::std::convert::From<&Self> for ResultX {
fn from(value: &ResultX) -> Self {
fn from(value: &Self) -> Self {
value.clone()
}
}
Expand Down Expand Up @@ -1542,7 +1542,7 @@ mod tests {
}

impl ::std::convert::From<&Self> for ResultX {
fn from(value: &ResultX) -> Self {
fn from(value: &Self) -> Self {
value.clone()
}
}
Expand Down
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
10 changes: 5 additions & 5 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 Expand Up @@ -1083,7 +1083,7 @@ impl TypeEntry {
}

impl ::std::convert::From<&Self> for #type_name {
fn from(value: &#type_name) -> Self {
fn from(value: &Self) -> Self {
value.clone()
}
}
Expand Down
2 changes: 1 addition & 1 deletion typify-impl/tests/generator.out
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ mod types {
BuckleMyShoe,
}
impl ::std::convert::From<&Self> for StringEnum {
fn from(value: &StringEnum) -> Self {
fn from(value: &Self) -> Self {
value.clone()
}
}
Expand Down
Loading