15
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rustだけでmain関数の前後に処理を行う

Last updated at Posted at 2018-07-03

世界はmain()から始まるんじゃ無かったんだよ!!

# ![feature(start)]

fn main() {
    println!("Hello, world!");
}

# [start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
    println!("Before the world!");
    main();
    println!("After the world!");
    0
}
$ cargo run
Before the world!
Hello, world!
After the world!

な、なんだってー

Q&A

いつ使うのこれ?

OS書くときとかはあると便利だったりするらしいですね
http://ykomatsu.github.io/rust/book-ja/no-stdlib.html

nightlyでしか動かないのでは?

夜中に書いてるから良いんです!

元ネタはC++の話ですよね?lasy_static!あれば十分じゃないの

せやな(´・ω・`)

参考

15
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?