Skip to content

Commit

Permalink
Merge pull request #172 from KronsyC/main
Browse files Browse the repository at this point in the history
Feat: Added Result<T, E> support
  • Loading branch information
NyxCode authored Jan 11, 2024
2 parents e0ded36 + a5c510a commit 618a164
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ts-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,23 @@ impl<T: TS> TS for Option<T> {
}
}

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

impl<T: TS> TS for Vec<T> {
fn name() -> String {
"Array".to_owned()
Expand Down

0 comments on commit 618a164

Please sign in to comment.