Skip to content

Commit

Permalink
format, fix linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
NyxCode committed Jan 11, 2024
1 parent e545a3a commit 4df0ffb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 13 additions & 9 deletions ts-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
//! Implement `TS` for `OrderedFloat` from ordered_float
//!
//! - `heapless-impl`
//!
//!
//! Implement `TS` for `Vec` from heapless
//!
//! - `no-serde-warnings`
Expand Down Expand Up @@ -464,20 +464,24 @@ impl<T: TS> TS for Option<T> {
}
}

impl<T : TS, E : TS> TS for Result<T, E>{
fn name() -> String{
impl<T: TS, E: TS> TS for Result<T, E> {
fn name() -> String {
unreachable!();
}
fn transparent() -> bool {
return true;
fn inline() -> String {
format!("{{ Ok : {} }} | {{ Err : {} }}", T::inline(), E::inline())
}
fn dependencies() -> Vec<Dependency>
where
Self: 'static {
[Dependency::from_ty::<T>(), Dependency::from_ty::<E>()].into_iter().flatten().collect()
Self: 'static,
{
[Dependency::from_ty::<T>(), Dependency::from_ty::<E>()]
.into_iter()
.flatten()
.collect()
}
fn inline() -> String {
format!("{{ Ok : {} }} | {{ Err : {} }}", T::inline(), E::inline())
fn transparent() -> bool {
true
}
}

Expand Down
6 changes: 3 additions & 3 deletions ts-rs/tests/issue-80.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ts_rs::TS;
use serde::Serialize;
use ts_rs::TS;

#[derive(TS, Serialize)]
#[ts(export)]
Expand All @@ -9,11 +9,11 @@ pub enum SomeTypeList {
#[ts(skip)]
skip_this: String,
},
Value2
Value2,
}

#[test]
fn issue_80() {
let ty = SomeTypeList::inline();
assert_eq!(ty, r#"{ "Value1": { } } | "Value2""#);
}
}

0 comments on commit 4df0ffb

Please sign in to comment.