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: wdt.rs
    path of file: ./repos/tock/chips/sam4l/src
    
    the code of the file until where you have to start completion: // Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR
    
    fn select_clock(&self, clock: WdtClockSource) {
        if !(WDT_REGS.cr.matches_all(From::from(clock))) {
            let clock_enabled = WDT_REGS.cr.is_set(Control::CEN);

            if clock_enabled {
                // Disable WDT clock before modifying source
                self.write_cr(Control::CEN::CLEAR);
                while WDT_REGS.cr.is_set(Control::CEN) {}
            }

            // Select Clock
            self.write_cr(From::from(clock));

            if clock_enabled {
                // Re-enable WDT clock after modifying source
                self.write_cr(Control::CEN::SET);
                while !WDT_REGS.cr.is_set(Control::CEN) {}
            }
        }
    }