In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use proc-macro-error in Rust". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use proc-macro-error in Rust".
Rust is a good choice for k8s for two reasons: 1. Rust provides some of the best support for WebAssembly compilation (described in more detail later). 1. To prove that the advantages of Rust can be applied to the Kubernetes ecosystem. The goal of proc-macro-errorproc-macro-error is to make error reporting in process macros easy and convenient. Quick overview of using examples:
Use proc_macro_error::*; use proc_macro::TokenStream; use syn:: {spanned::Spanned, DeriveInput, ItemStruct, Fields, Attribute, parse_macro_input}; use quote::quote; fn process_attrs (attrs: & [Attribute])-> Vec {attrs .iter () .filter _ map (| attr | match process_attr (attr) {Ok (res) = > Some (res), Err (msg) = > {emit_error! (attr, "Invalid attribute: {}", msg) None}}) .pub fn make_answer ()} fn process_fields (_ attrs: & Fields)-> Vec {/ / processing fields in pretty much the same way as attributes unimplemented! ()} # [proc_macro] # [proc_macro_error] pub fn make_answer (input: TokenStream)-> TokenStream {let input = parse_macro_input! (input as ItemStruct); let attrs = process_attrs (& input.attrs)
/ / abort right now if some errors were encountered / / at the attributes processing stage abort_if_dirty (); let fields = process_fields (& input.fields) / / no need to think about emitted errors / / # [proc_macro_error] will handle them for you / just return a TokenStream as you normally would quote! (/ * stuff * /). Into ()} Thank you for reading. This is the content of "how to use proc-macro-error in Rust". After the study of this article, I believe you have a deeper understanding of how to use proc-macro-error in Rust. The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.