Registry / utility / ctor
library1.0.7rscratesunverified

Global, no_std-compatible constructors for all platforms that run before main (like C/C++ __attribute__((constructor)))

# Cargo.toml [dependencies] ctor = "1.0.7"
INSTALL
IMPORT
SIG · CTOR
C
ctor
utilityrustv1.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ctor
use ctor::ctor;

Define a function that runs automatically before main.

use ctor::ctor; #[ctor] fn init() { println!("This runs before main!"); } fn main() { println!("Main function"); }
Debug
Known issues
gotchaConstructors may not run in the expected order across different platforms.
fix
Avoid relying on initialization order; use lazy_static or once_cell for ordered initialization.
affects: >=1.0
Upgrade
Version history
1.0.7latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
ctor — cargo add ctor · libregistry