chore: improves formatting
mellbacon committed
Oct 1, 2023 at 16:26 UTC
33c913d74e1dffb8103f98716e5b6ea14b2c2fc0
2 files changed
+5
-8
src-tauri/build.rs
+1
-1
@@ -1,3 +1,3 @@
1
fn main() {
2
- tauri_build::build()
2
+ tauri_build::build()
3
}
src-tauri/src/encoding.rs
+4
-7
@@ -2,7 +2,7 @@
2
pub enum BOM {
3
BigEndian,
4
LittleEndian,
5
- None
5
+ None,
6
}
7
8
pub fn convert_to_u16(str: &str, bom: BOM) -> Vec<u8> {
@@ -13,14 +13,12 @@ pub fn convert_to_u16(str: &str, bom: BOM) -> Vec<u8> {
13
.chain(str.encode_utf16())
14
.flat_map(|word| word.to_be_bytes())
15
.collect::<Vec<_>>();
16
- }
17
- else if bom == BOM::LittleEndian {
16
+ } else if bom == BOM::LittleEndian {
17
bytes = core::iter::once(0xFFFE)
18
.chain(str.encode_utf16())
19
.flat_map(|word| word.to_le_bytes())
20
.collect::<Vec<_>>();
22
- }
23
- else if bom == BOM::None {
21
+ } else if bom == BOM::None {
22
let utf16 = str.encode_utf16();
23
24
// autodetect endianess
@@ -28,8 +26,7 @@ pub fn convert_to_u16(str: &str, bom: BOM) -> Vec<u8> {
26
bytes = utf16
27
.flat_map(|word| word.to_be_bytes())
28
.collect::<Vec<_>>();
31
- }
32
- else {
29
+ } else {
30
bytes = utf16
31
.flat_map(|word| word.to_le_bytes())
32
.collect::<Vec<_>>();