You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: gamma.rs
    path of file: ./repos/bitcode/src/encoding
    
    the code of the file until where you have to start completion: use super::prelude::*;
use crate::nightly::ilog2_non_zero_u64;
use std::num::NonZeroU64;

#[derive(Copy, Clone)]
pub struct Gamma;
impl Encoding for Gamma {
    fn zigzag(self) -> bool {
        true
    }

    #[inline(always)]
    fn write_u64<const BITS: usize>(self, writer: &mut imp
    
    fn write_u64<const BITS: usize>(self, writer: &mut impl Write, word: Word) {
        debug_assert!(BITS <= WORD_BITS);
        if BITS != WORD_BITS {
            debug_assert_eq!(word, word & ((1 << BITS) - 1));
        }

        // https://en.wikipedia.org/wiki/Elias_gamma_coding
        // Gamma can't encode 0 so add 1.
        if let Some(nz) = NonZeroU64::new(word.wrapping_add(1)) {
            let zero_bits = ilog2_non_zero_u64(nz) as usize;
            writer.write_zeros(zero_bits);

            // Special case max value as BITS zeros.
            if BITS != 64 && word == (u64::MAX >> (64 - BITS)) {
                return;
            }

            let integer_bits = zero_bits + 1;

            // Rotate bits mod `integer_bits` instead of reversing since it's faster.
            // 00001bbb -> 0000bbb1
            let rotated = (nz.get() << 1 & !((1 << 1) << zero_bits)) | 1;
            writer.write_bits(rotated, integer_bits);
        } else {
            // Special case u64::MAX as as 64 zeros (based on u64::MAX + 1 == 0 so we skip branch in ilog2).
            writer.write_zeros(64);
        }
    }