Begin implementing RaiseTo trait

CandyCorvid
Jul 13, 2023, 1:24 PM
2C4IMVXFZ2JTPWLBFQAY5SVVOJD6AUECPBMZ2UEMU3BBXFDLMS4AC

Dependencies

  • [2] 3VVQWLOX Major refactor: modularisation
  • [*] WGRFJRTE Add tests, rename Status to Header, implement redirect and proper input handling

Change contents

  • edit in src/media.rs at line 3
    [4.507]
    [4.507]
    /// Modify the lifetime of self by serialising the data into the target.
    /// The output will reference the copy in the target
    trait RaiseTo {
    type Target;
    type Output<'a>;
    fn raise_to<'a>(&self, target: &'a mut Self::Target) -> Self::Output<'a>;
    }
  • edit in src/media.rs at line 15
    [4.595]
    [4.790]
    }
    impl<'a> RaiseTo for Media<'a> {
    type Target = String;
    type Output<'a> = Media<'a>;
    fn raise_to<'a>(&self, target: &'a mut Self::Target) -> Self::Output<'a> {
    match self {
    Media::Gemini(gem) => todo!(),
    Media::Text(text) => text.raise_to(target),
    }
    }
  • edit in src/media.rs at line 28
    [4.792]
    [4.792]
  • edit in src/media.rs at line 204
    [2.896]
    [4.4828]
    impl<'tl> RaiseTo for TextLine<'tl> {
    type Target = String;
    type Output<'a> = TextLine<'a>;
    fn raise_to<'a>(&self, target: &'a mut String) -> Self::Output<'a> {
    let old_end = target.len();
    target.push_str(self.0);
    TextLine(&target[old_end..])
    }
    }
    impl<'st> RaiseTo for &'st str {
    type Target = String;
    type Output<'a> = &'a str;
    fn raise_to<'a>(&self, target: &'a mut String) -> Self::Output<'a> {
    let old_end = target.len();
    target.push_str(self);
    &target[old_end..]
    }
    }