What it does
This is from a configuration of rustfmt force_explicit_abi.
When using extern to specify an external function, it's advised to explicitly specify C-ABI.
Although the default is C-ABI if extern is not specified, it is a convention for Rust to specify it explicitly.
Advantage
- It is a convention for Rust to specify it explicitly when using
extern to specify an external function;
- Clippy can support to check such scenario that rustfmt can automatically format.
Drawbacks
No response
Example
bad case:
// Noncompliant
extern {
pub static lorem: c_int;
}
good case:
// Compliant
extern "C" {
pub static lorem: c_int;
}
extern "Rust" {
type MyType;
fn f(&self) -> usize;
}
What it does
This is from a configuration of rustfmt
force_explicit_abi.When using
externto specify an external function, it's advised to explicitly specifyC-ABI.Although the default is
C-ABIifexternis not specified, it is a convention for Rust to specify it explicitly.Advantage
externto specify an external function;Drawbacks
No response
Example
bad case:
good case: