1, мне недостаточно знаний, чтобы переписать это без unsafe.
Consumes and leaks the Vec, returning a mutable reference to the contents, &'a mut [T]. Note that the type T must outlive the chosen lifetime 'a. If the type has only static references, or none at all, then this may be chosen to be 'static.
As of Rust 1.57, this method does not reallocate or shrink the Vec, so the leaked allocation may include unused capacity that is not part of the returned slice.
This function is mainly useful for data that lives for the remainder of the program’s life. Dropping the returned reference will cause a memory leak.
Пример: оригинальная ссылка дпуостим: https://qna.habr.com
она превращается в: fsdf.namedomain
Плюс в моей стране это не нонейм, а сертифицированная марка
По этому я и хочу сделать это так, чтобы причина была не явной, типа родительского контроля
На строке, где
*new_slice.offset(0) = len as u8;
Сейчас разберусь, что это значит и имеет ли это отношение к проблеме.
Формально, UB может к этому приводить.