pub fn truncate(&mut self, len: usize) {
        if len >= self.len() {
            return;
        }
        if len == 0 {
            self.clear();
            return;
        }

        if len <= self.ascii_len {
            self.ascii_len = len;
            self.is_utf8 = true;
        } else {
            self.is_utf8 = if self.is_utf8 {
                is_utf8_leading_byte(self.bytes[len])
            } else {
                from_utf8(&self.bytes[..len]).is_ok()
            };
        }
        self.bytes.truncate(len);
        self.debug_validate();
    }
/// Truncates the byte string to the given length.
Truncates the byte string to the given length.
Truncates the byte string to the given length .
pub fn truncate(&mut self, len: usize) {
        if len >= self.len() {
            return;
        }
        if len == 0 {
            self.clear();
            return;
        }
        if len <= self.ascii_len {
            self.ascii_len = len;
            self.is_utf8 = true;
        } else {
            self.is_utf8 = if self.is_utf8 {
                is_utf8_leading_byte(self.bytes[len])
            } else {
                from_utf8(&self.bytes[..len]).is_ok()
            };
        }
        self.bytes.truncate(len);
        self.debug_validate();
    }
pub fn truncate ( & mut self , len : usize ) { if len >= self . len ( ) { return ; } if len == 0 { self . clear ( ) ; return ; } if len <= self . ascii_len { self . ascii_len = len ; self . is_utf8 = true ; } else { self . is_utf8 = if self . is_utf8 { is_utf8_leading_byte ( self . bytes [ len ] ) } else { from_utf8 ( & self . bytes [ .. len ] ) . is_ok ( ) } ; } self . bytes . truncate ( len ) ; self . debug_validate ( ) ; }
Truncates the byte string to the given length.
Truncates the byte string to the given length .
&mut self
len
usize
&mut self
len
usize