rfmod/utils.rs
1/*
2* Rust-FMOD - Copyright (c) 2018 Gomez Guillaume.
3*
4* The Original software, FmodEx library, is provided by FIRELIGHT TECHNOLOGIES.
5*
6* This software is provided 'as-is', without any express or implied warranty.
7* In no event will the authors be held liable for any damages arising from
8* the use of this software.
9*
10* Permission is granted to anyone to use this software for any purpose,
11* including commercial applications, and to alter it and redistribute it
12* freely, subject to the following restrictions:
13*
14* 1. The origin of this software must not be misrepresented; you must not claim
15* that you wrote the original software. If you use this software in a product,
16* an acknowledgment in the product documentation would be appreciated but is
17* not required.
18*
19* 2. Altered source versions must be plainly marked as such, and must not be
20* misrepresented as being the original software.
21*
22* 3. This notice may not be removed or altered from any source distribution.
23*/
24
25#[macro_export]
26macro_rules! from_utf8 {
27 ($vec:expr) => {{
28 let mut pos = 0;
29
30 for x in $vec.iter() {
31 pos += 1;
32 if *x == 0 {
33 break
34 }
35 }
36 unsafe { $vec.set_len(pos); }
37 String::from_utf8_lossy(&$vec).into()
38 }}
39}