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: bit.rs
    path of file: ./repos/Fyrox/fyrox-ui/src
    
    the code of the file until where you have to start completion: //! A widget that shows numeric value as a set of individual bits allowing switching separate bits.

use crate::{
    check_box::{CheckBoxBuilder, CheckBoxMessage},
    core::{
        num_traits::{NumCast, One, Zero},
        pool::Handle,
        reflect::prelude::*,
        type_traits::prelude::*,
        uuid::uuid,
        visitor::prelude::*,
    },
    define_constructor,
    message::UiMessage,
    widget::{Widget, WidgetBuilder},
    wrap_panel::WrapPanelBuilder,
    BuildContext, Control, MessageDirection, MouseButton, Orientation, Thickness, UiNode,
    UserInterface, WidgetMessage,
};
use fyrox
    
    fn handle_routed_message(&mut self, ui: &mut UserInterface, message: &mut UiMessage) {
        self.widget.handle_routed_message(ui, message);

        if let Some(CheckBoxMessage::Check(Some(value))) = message.data() {
            if message.direction() == MessageDirection::FromWidget {
                if let Some(bit_index) = self
                    .bit_switches
                    .iter()
                    .position(|s| *s == message.destination())
                {
                    let new_value = if *value {
                        set_bit(self.value, bit_index)
                    } else {
                        reset_bit(self.value, bit_index)
                    };

                    ui.send_message(BitFieldMessage::value(
                        self.handle,
                        MessageDirection::ToWidget,
                        new_value,
                    ));
                }
            }
        } else if let Some(BitFieldMessage::Value(value)) = message.data() {
            if message.destination() == self.handle
                && message.direction() == MessageDirection::ToWidget
                && *value != self.value
            {
                self.value = *value;
                self.sync_switches(ui);
                ui.send_message(message.reverse());
            }
        } else if let Some(WidgetMessage::MouseDown { button, .. }) = message.data() {
            if *button == MouseButton::Right {
                for (index, bit) in self.bit_switches.iter().cloned().enumerate() {
                    if ui.node(bit).has_descendant(message.destination(), ui) {
                        let new_value = if is_bit_set(self.value, index) {
                            !(T::one() << T::from(index).unwrap_or_default())
                        } else {
                            T::one() << T::from(index).unwrap_or_default()
                        };

                        ui.send_message(BitFieldMessage::value(
                            self.handle,
                            MessageDirection::ToWidget,
                            new_value,
                        ));
                    }
                }
            }
        }
    }