After running the function set_enable in the following example, I would like to check if enabled is true.
How do I invoke enabled in the main function?
structure Gpio{
enabled:bool,
direction:bool,
output:bool,
//periph —GPIO_CONFIG,
}
impl Gpio{
pubfn set_enable(&mut self){
self.enabled = true;
}
pubfn set_direction(&mut self){
if self.enabled!=true{
return;
}
self.direction=true;
}
pubfn set_output_status(&mut self){
if self.enabled!=true{
return;
}
if self.direction!=true{
return;
}
self.output = true;
}
}
US>fnmain(){
let mutpin = Gpio {
enabled: false,
direction: false,
output: false,
};
println!
}
I just called it and it came out without any problems.
fnmain(){
let mutpin = Gpio {
enabled: false,
direction: false,
output: false,
};
if pin.enabled {
print!("pin.enabled is true");
} else{
print!("pin.enabled is false");
}
}
© 2024 OneMinuteCode. All rights reserved.