File tree Expand file tree Collapse file tree 4 files changed +35
-2
lines changed Expand file tree Collapse file tree 4 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,10 @@ struct Rectangle {
5959 height: u32,
6060}
6161
62- impl Tldr for Rectangle {
62+ impl Tldr<String> for Rectangle {
6363 type Error = Box<dyn Error>;
6464
65- fn what(&self, _ctx: &TldrContext) -> TldrResult<T > {
65+ fn what(&self, _ctx: &TldrContext) -> TldrResult<String > {
6666 Ok(Some(format!("A rectangle with a width of {} and a height of {}.", self.width, self.height)))
6767 }
6868}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use core::{fmt, str::FromStr};
55
66/// ```rust
77/// # use tldr_traits::TldrLanguage;
8+ /// let language = TldrLanguage::default(); // this is the same as...
89/// let language = TldrLanguage::English;
910/// ```
1011#[ non_exhaustive]
Original file line number Diff line number Diff line change 33use crate :: { TldrContext , TldrResult } ;
44use alloc:: string:: String ;
55
6+ /// ```rust
7+ /// # use tldr_traits::{Tldr, TldrContext, TldrResult};
8+ /// # use core::error::Error;
9+ /// struct Rectangle {
10+ /// width: u32,
11+ /// height: u32,
12+ /// }
13+ ///
14+ /// impl Tldr<String> for Rectangle {
15+ /// type Error = Box<dyn Error>;
16+ ///
17+ /// fn what(&self, _ctx: &TldrContext) -> TldrResult<String> {
18+ /// Ok(Some(format!("A rectangle with a width of {} and a height of {}.", self.width, self.height)))
19+ /// }
20+ /// }
21+ /// ```
22+ ///
623/// See: https://en.wikipedia.org/wiki/Five_Ws
724/// See: https://en.wikipedia.org/wiki/Interrogative_word
825pub trait Tldr < T = String > {
Original file line number Diff line number Diff line change 33use crate :: Tldr ;
44use alloc:: { boxed:: Box , string:: String } ;
55
6+ /// ```rust
7+ /// # use tldr_traits::{Tldr, TldrSummary, ToTldr};
8+ /// struct Rectangle {
9+ /// width: u32,
10+ /// height: u32,
11+ /// }
12+ ///
13+ /// impl ToTldr<String> for Rectangle {
14+ /// type Error = Box<dyn core::error::Error>;
15+ ///
16+ /// fn to_tldr(&self) -> Box<dyn Tldr<String, Error = Self::Error>> {
17+ /// todo!() // FIXME
18+ /// }
19+ /// }
20+ /// ```
621pub trait ToTldr < T = String > {
722 /// The associated error type.
823 ///
You can’t perform that action at this time.
0 commit comments