jweinst1
5/4/2019 - 2:05 AM

construct struct with string slices from living string

construct struct with string slices from living string


// All the members have the same lifetime
#[derive(Debug)]
struct Fact<'s>(&'s str, &'s str, &'s str);


fn main() {
   let st = 1;
   let end = 5;
   let text = String::from("abdefghijksdf");
   let slc = &text[st..end];
   println!("{}", slc);
   let cus2 = Fact(&text[0..2], &text[1..4], &text[2..5]);
   println!("{:?}", cus2);
}