代码拉取完成,页面将自动刷新
use std::{env, fs};
use std::path::Path;
use quote::ToTokens;
use reqwest::blocking::get;
use syn::{File, Item};
fn main() {
let commit = env::var("RUSTC_COMMIT").unwrap_or(String::from("master"));
let text = get(format!("https://raw.githubusercontent.com/rust-lang/rust/{commit}/compiler/rustc_span/src/symbol.rs"))
.unwrap()
.text()
.unwrap();
let result = syn::parse_str::<File>(&text).unwrap();
for item in result.items {
if let Item::Macro(m) = item {
let name = m.mac.path.segments.to_token_stream().to_string();
if name == "symbols" {
let text = m.mac.to_token_stream().to_string();
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("symbol.rs");
fs::write(dest_path, &text).unwrap();
return;
}
}
}
panic!("Can't find `symbols` macro call");
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。