How do I close a serial port that I've opened? I can't see any hint about how to do this in the docs for serialport.
答案 0 :(得分:1)
The trait Serialport
itself does not offer such functionality1.
However the only implementor is TTYPort
and its doc states:
The port will be closed when the value is dropped.
If you look at the drop
implementation, you can verify this behavior.
So, you can either use std::mem::drop
directly or when the value goes out of scope the Drop
implementation will be called (see the book about this chapter.).
1 I would suggest opening a issue on the GitHub repository and request the functionality.