Debian Codegraph @

src/common/int.rs

raw symbols SCIP
1 use synrust-analyzer cargo syn 2.0.119 crate/::{spannedrust-analyzer cargo syn 2.0.119 spanned/::Spannedrust-analyzer cargo syn 2.0.119 spanned/Spanned#, Exprrust-analyzer cargo syn 2.0.119 expr/Expr#, Litrust-analyzer cargo syn 2.0.119 lit/Lit#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, MetaNameValuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#, UnOprust-analyzer cargo syn 2.0.119 op/UnOp#};
2
3 use superrust-analyzer cargo educe 0.6.0 common/::pathrust-analyzer cargo educe 0.6.0 common/path/::path_to_stringrust-analyzer cargo educe 0.6.0 common/path/path_to_string().;
4
5 #[inline]
6 pub(craterust-analyzer cargo educe 0.6.0 crate/) fn meta_name_value_2_isizerust-analyzer cargo educe 0.6.0 common/int/meta_name_value_2_isize().(name_value: &MetaNameValuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<isize> {
7 match &name_value.valuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#value. {
8 Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Litrust-analyzer cargo syn 2.0.119 expr/Expr#Lit#(lit) => match &lit.litrust-analyzer cargo syn 2.0.119 expr/ExprLit#lit. {
9 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Strrust-analyzer cargo syn 2.0.119 lit/Lit#Str#(lit) => {
10 return lit
11 .valuerust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]value().()
12 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<isize>()
13 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|error| synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(lit.spanrust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]span().(), error))
14 },
15 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Intrust-analyzer cargo syn 2.0.119 lit/Lit#Int#(lit) => return lit.base10_parserust-analyzer cargo syn 2.0.119 lit/impl#[LitInt]base10_parse().(),
16 _ => (),
17 },
18 Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Unaryrust-analyzer cargo syn 2.0.119 expr/Expr#Unary#(unary) => {
19 if let UnOprust-analyzer cargo syn 2.0.119 op/UnOp#::Negrust-analyzer cargo syn 2.0.119 op/UnOp#Neg#(_) = unary.oprust-analyzer cargo syn 2.0.119 expr/ExprUnary#op. {
20 if let Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Litrust-analyzer cargo syn 2.0.119 expr/Expr#Lit#(lit) = unary.exprrust-analyzer cargo syn 2.0.119 expr/ExprUnary#expr..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][`AsRef<T>`]as_ref().() {
21 if let Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Intrust-analyzer cargo syn 2.0.119 lit/Lit#Int#(lit) = &lit.litrust-analyzer cargo syn 2.0.119 expr/ExprLit#lit. {
22 let s = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("-{}", lit.base10_digitsrust-analyzer cargo syn 2.0.119 lit/impl#[LitInt]base10_digits().());
23
24 return s
25 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<isize>()
26 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|error| synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(lit.spanrust-analyzer cargo syn 2.0.119 lit/impl#[LitInt]span().(), error));
27 }
28 }
29 }
30 },
31 _ => (),
32 }
33
34 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(
35 name_value.valuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#value..spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().(),
36 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("expected `{path} = integer`", path = path_to_stringrust-analyzer cargo educe 0.6.0 common/path/path_to_string().(&name_value.pathrust-analyzer cargo syn 2.0.119 attr/MetaNameValue#path.)),
37 ))
38 }
39
40 #[inline]
41 pub(craterust-analyzer cargo educe 0.6.0 crate/) fn meta_2_isizerust-analyzer cargo educe 0.6.0 common/int/meta_2_isize().(meta: &Metarust-analyzer cargo syn 2.0.119 attr/Meta#) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<isize> {
42 match &meta {
43 Metarust-analyzer cargo syn 2.0.119 attr/Meta#::NameValuerust-analyzer cargo syn 2.0.119 attr/Meta#NameValue#(name_value) => meta_name_value_2_isizerust-analyzer cargo educe 0.6.0 common/int/meta_name_value_2_isize().(name_value),
44 Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Listrust-analyzer cargo syn 2.0.119 attr/Meta#List#(list) => {
45 let lit = list.parse_argsrust-analyzer cargo syn 2.0.119 attr/impl#[MetaList]parse_args().::<Litrust-analyzer cargo syn 2.0.119 lit/Lit#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
46
47 match &lit {
48 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Strrust-analyzer cargo syn 2.0.119 lit/Lit#Str#(lit) => {
49 lit.valuerust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]value().().parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<isize>().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|error| synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(lit.spanrust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]span().(), error))
50 },
51 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Intrust-analyzer cargo syn 2.0.119 lit/Lit#Int#(lit) => lit.base10_parserust-analyzer cargo syn 2.0.119 lit/impl#[LitInt]base10_parse().(),
52 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(lit.spanrust-analyzer cargo syn 2.0.119 lit/value/impl#[Lit]span().(), "not an integer")),
53 }
54 },
55 Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Pathrust-analyzer cargo syn 2.0.119 attr/Meta#Path#(path) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(
56 path.spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().(),
57 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
58 "expected `{path} = integer` or `{path}(integer)`",
59 path = path_to_stringrust-analyzer cargo educe 0.6.0 common/path/path_to_string().(path)
60 ),
61 )),
62 }
63 }