Skip to content

Commit

Permalink
Upgrade toolchain, fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeckwith committed Sep 7, 2024
1 parent 6ff9364 commit 6331202
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## NEXT

* Export `Blob` newtype wrapper around `Vec<u8>` which has the Typescript type [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).

## v0.5.10

* Add `TypeDef` impl for `Ipv4Addr` and `Ipv6Addr` ([#31](https://github.com/dbeckwith/rust-typescript-type-def/pull/31)).
Expand Down
2 changes: 1 addition & 1 deletion derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ ident_case = "1.0.1"
proc-macro-error = "1.0.4"
proc-macro2 = "1.0.27"
quote = "1.0.9"
syn = { version = "1.0.73", default_features = false, features = ["visit-mut"] }
syn = { version = "1.0.73", default-features = false, features = ["visit-mut"] }
28 changes: 11 additions & 17 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,23 +400,17 @@ fn fields_to_type_expr(
}
***flatten
});
let flatten_exprs = fields.iter().filter_map(
|TypeDefField {
ty,
type_of,
flatten,
..
}| {
flatten.then(|| {
let ty = if let Some(type_of) = type_of {
&***type_of
} else {
ty
};
type_expr_ref(ty, Some(generics))
})
},
);
let flatten_exprs = fields
.iter()
.filter(|&TypeDefField { flatten, .. }| ***flatten)
.map(|TypeDefField { ty, type_of, .. }| {
let ty = if let Some(type_of) = type_of {
&***type_of
} else {
ty
};
type_expr_ref(ty, Some(generics))
});
// always put flatten exprs first
let exprs = flatten_exprs.chain((!all_flatten).then(|| {
// if there are some non-flattened fields, make an expr out of them
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.67.1"
channel = "1.80.0"
components = []
4 changes: 2 additions & 2 deletions src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,13 @@ impl Default for DefinitionFileOptions<'_> {
/// Note that the TypeScript code generated by this library is not very
/// human-readable. To make the code human-readable, use a TypeScript code
/// formatter (such as [Prettier](https://prettier.io/)) on the output.
pub fn write_definition_file<W, T: ?Sized>(
pub fn write_definition_file<W, T>(
writer: W,
options: DefinitionFileOptions<'_>,
) -> io::Result<Stats>
where
W: io::Write,
T: TypeDef,
T: ?Sized + TypeDef,
{
write_definition_file_from_type_infos(writer, options, &[&T::INFO])
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ pub use crate::emit::{
write_definition_file, write_definition_file_from_type_infos,
DefinitionFileOptions, Stats, TypeDef,
};
pub use crate::impls::Blob;

/// A derive proc-macro for the [`TypeDef`] trait.
///
Expand Down

0 comments on commit 6331202

Please sign in to comment.