Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

trim

Public Function
std.fmt.parse_float.decimal.Decimal.trim
pub fn trim(self: *Self) void

Trim trailing zeroes from the buffer

Params

File

fmt/parse_float/decimal.zig:96
96
97
98
99
100
101
102
103
104
105
106
107
108
        pub fn trim(self: *Self) void {
            // All of the following calls to `Self::trim` can't panic because:
            //
            //  1. `parse_decimal` sets `num_digits` to a max of `max_digits`.
            //  2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
            //  3. `left_shift` `num_digits` to a max of `max_digits`.
            //
            // Trim is only called in `right_shift` and `left_shift`.
            std.debug.assert(self.num_digits <= max_digits);
            while (self.num_digits != 0 and self.digits[self.num_digits - 1] == 0) {
                self.num_digits -= 1;
            }
        }