util module
This commit is contained in:
parent
0917ef441d
commit
fff61e0adb
@ -5,4 +5,4 @@ pub mod cipherkeys;
|
||||
pub mod network;
|
||||
pub mod serverstate;
|
||||
pub mod client;
|
||||
|
||||
pub mod util;
|
||||
|
11
src/common/util.rs
Normal file
11
src/common/util.rs
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
pub fn array_to_utf8<const X: usize>(array: [u8; X]) -> Result<String, std::string::FromUtf8Error> {
|
||||
String::from_utf8(array.to_vec())
|
||||
.map(|mut s| {
|
||||
if let Some(index) = s.find("\u{0}") {
|
||||
s.truncate(index);
|
||||
}
|
||||
s
|
||||
})
|
||||
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
#![feature(async_await)]
|
||||
#![feature(const_generics)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate diesel;
|
||||
|
||||
pub mod common;
|
||||
pub mod schema;
|
||||
|
Loading…
x
Reference in New Issue
Block a user