udp 3.1.0

A lightweight and efficient Rust library for building UDP servers with request-response handling.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/// Removes trailing zeros from a byte vector.
///
/// # Arguments
///
/// - `&mut Vec<u8>` - Mutable reference to the byte vector.
///
/// # Returns
///
/// - `Vec<u8>` - New vector with trailing zeros removed.
pub fn remove_trailing_zeros(data: &mut Vec<u8>) -> Vec<u8> {
    if let Some(last_non_zero_pos) = data.iter().rposition(|&x| x != 0) {
        data.truncate(last_non_zero_pos + 1);
    } else {
        data.clear();
    }
    data.clone()
}