zoukankan      html  css  js  c++  java
  • cargo expand用于查看被宏隐藏的代码

    一,目前这个需要安装nightly的toolchain,rustup toolchain install nightly-x86_64-unknown-linux-gnu

    二,用这个命令安装:cargo +nightly install cargo-expand

    三,到具体的项目里去,比如demo-01项目,然后用了tide和async-std,只有一个代码文件为:

    use std::result::Result;
    
    #[async_std::main]
    async fn main() -> Result<(), std::io::Error>{
        println!("Hello, world!");
        Ok(())
    }

    这里我一直不知道#[async_std::main]到底是干嘛用的,而且之前一直以为这个是async-std提供的功能,现在才发现是tide提供的宏(其他框架可能也提供了类似的);

    四,运行cargo expand --bin demo-01来展开被宏隐藏的代码,得到:

    #![feature(prelude_import)]
    #[prelude_import]
    use std::prelude::v1::*;
    #[macro_use]
    extern crate std;
    use std::result::Result;
    fn main() -> Result<(), std::io::Error> {
        async fn main() -> Result<(), std::io::Error> {
            {
                {
                    ::std::io::_print(::core::fmt::Arguments::new_v1(
                        &["Hello, world!
    "],
                        &match () {
                            () => [],
                        },
                    ));
                };
                Ok(())
            }
        }
        async_std::task::block_on(async { main().await })
    }
  • 相关阅读:
    【xinsir】githook之precommit分享
    node进程一些信号的意义
    ES6篇
    Webpack4篇
    Node篇
    Vuex篇
    WebStorage篇
    HTML5篇
    html5语义化标签大全
    emmet语法
  • 原文地址:https://www.cnblogs.com/silentdoer/p/13239028.html
Copyright © 2011-2022 走看看