Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allow attribute for new Rust version #15

Merged
merged 2 commits into from
May 4, 2024
Merged
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
1 change: 1 addition & 0 deletions src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::ops::Add;

#[derive(Clone, Debug)]
#[allow(dead_code)]
pub struct Error;

pub trait Printer<Context> {
Expand Down
25 changes: 15 additions & 10 deletions src/rust/model_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl RefCache {
fn serialize() -> RustPrinter {
rust_name("serde", "Serialize")
}

fn deserialize() -> RustPrinter {
rust_name("serde", "Deserialize")
}
Expand Down Expand Up @@ -316,12 +317,14 @@ fn extract_enum_case(
data_type: ref_type_name(reference, ref_cache)?,
})
} else {
Err(Error::unimplemented(
"Can't find model type reference in enum case schema.",
))
Err(Error::unimplemented(format!(
"Can't find model type reference in enum case schema {schema_name}.",
)))
}
}
_ => Err(Error::unimplemented("allOf schema expected for enum case")),
_ => Err(Error::unimplemented(format!(
"allOf schema expected for enum case in {schema_name}"
))),
}
}

Expand Down Expand Up @@ -415,25 +418,27 @@ pub fn model_gen(reference: &str, open_api: &OpenAPI, ref_cache: &mut RefCache)
.unwrap_or_else(unit);

#[rustfmt::skip]
let code = unit() +
let code = unit() +
derive_line() +
line(unit() + "pub enum " + &name + " {") +
indented(
cases
) +
line(unit() + "}") +
NewLine +
line(unit() + "#[allow(clippy::to_string_trait_impl)]") +
NewLine +
line(unit() + "impl ToString for " + &name + "{") +
indented(
line("fn to_string(&self) -> String {") +
indented(
line("match self {") +
indented(
match_cases
line("match self {") +
indented(
match_cases
) +
line("}")
) +
line("}")
) +
line("}")
) +
line("}");

Expand Down
1 change: 1 addition & 0 deletions src/rust/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl RustContext {
}
}

#[allow(clippy::to_string_trait_impl)]
impl ToString for RustContext {
#[allow(unstable_name_collisions)]
fn to_string(&self) -> String {
Expand Down
1 change: 1 addition & 0 deletions src/rust/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub enum IntFormat {
I64,
}

#[allow(clippy::to_string_trait_impl)]
impl ToString for IntFormat {
fn to_string(&self) -> String {
match self {
Expand Down
Loading