I am trying to use "Fast linear time & space suffix arrays for Rust" suffix lib. And as far as I can tell the constructor requires a static &str to be passed to it. But my program is generating a Vec for which i would need to create a suftab and run numerous queries on it.
how to convert Vec<u8> to a type required by suffix in order to be able to use it? My idea was:
Vec<u8> -> ?how to do this? -> let mystr : &'static [u8] =... -> SuffixTable::new(std::str::from_utf8(mystr).unwrap())
but i do not know how to do that. Can anyone help here?
SuffixTable::new doesn't have a 'static bound for the parameter. And I was able to call it without a compile error:
use suffix::SuffixTable;
let v = vec![1_u8, 2, 3];
let s = std::str::from_utf8(&v).unwrap();
let _t = SuffixTable::new(s);
If that doesn't work for you and you get a compiler error, be sure to post the entire error from running cargo in the terminal. Often the error has hints and other information. And be sure to post all the code related to the error.
I am very embarrassed here. This is clear example of a X-Y problem on my behalf. I was trying to integrate a third party code that had this set a struct:
and then later in test simply called its constructor as :
RefTab::new(b"XYZZZXYYX");
I saw the test and the library call suffix = "1.3.0" and assumed what followed in my question. Though jumpnbrownweasel did answer the initial question pointing out i am talking nonsense , the Y issue i was looking a solution for, was provided by quinedot who provided also a clear explanation which i used to implement my specific use case. Ergo I will accept quinedot's solution as an answer (but heart both), but if any one objects i am ok with creating another post and accepting both as the correct answers for the future wanderers.