Skip to content

Commit

Permalink
output Result<T, E>
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 authored Oct 21, 2023
1 parent 44c4b73 commit bad2f72
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ts-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,28 @@ impl<T: TS> TS for Option<T> {
}
}


impl<T: TS, E: TS> TS for Result<T, E> {
fn name() -> String {
unreachable!();
}

fn inline() -> String {
format!("{{ ok : {} }} | {{ err : {} }}", T::inline(), E::inline())
}

fn dependencies() -> Vec<Dependency>
where
Self: 'static,
{
[Dependency::from_ty::<T>()].into_iter().flatten().collect()
}

fn transparent() -> bool {
true
}
}

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

0 comments on commit bad2f72

Please sign in to comment.