Download Dataset_Construction/projects/libp2p/rust/swarm-derive/src/syn_ext.rs from SYSUSELab/RustRepoTrans: direct link, hf CLI and curl.
- Browser
- Download file 434 Bytes
-
https://huggingface.co/datasets/SYSUSELab/RustRepoTrans/resolve/main/Dataset_Construction/projects/libp2p/rust/swarm-derive/src/syn_ext.rs
- Command line
-
hf download hf://datasets/SYSUSELab/RustRepoTrans/Dataset_Construction/projects/libp2p/rust/swarm-derive/src/syn_ext.rs
-
curl -L -o syn_ext.rs https://huggingface.co/datasets/SYSUSELab/RustRepoTrans/resolve/main/Dataset_Construction/projects/libp2p/rust/swarm-derive/src/syn_ext.rs
434 Bytes
| use syn::{Expr, ExprLit, Lit}; | |
| pub(crate) trait RequireStrLit { | |
| fn require_str_lit(&self) -> syn::Result<String>; | |
| } | |
| impl RequireStrLit for Expr { | |
| fn require_str_lit(&self) -> syn::Result<String> { | |
| match self { | |
| Expr::Lit(ExprLit { | |
| lit: Lit::Str(str), .. | |
| }) => Ok(str.value()), | |
| _ => Err(syn::Error::new_spanned(self, "expected a string literal")), | |
| } | |
| } | |
| } | |