MCPcopy Index your code
hub / github.com/RustPython/RustPython / _optional_str

Method _optional_str

crates/derive-impl/src/util.rs:165–188  ·  view source on GitHub ↗
(&self, key: &str)

Source from the content-addressed store, hash-verified

163 }
164
165 pub fn _optional_str(&self, key: &str) -> Result<Option<String>> {
166 let value = if let Some((_, meta)) = self.meta_map.get(key) {
167 let Meta::NameValue(syn::MetaNameValue {
168 value:
169 syn::Expr::Lit(syn::ExprLit {
170 lit: syn::Lit::Str(lit),
171 ..
172 }),
173 ..
174 }) = meta
175 else {
176 bail_span!(
177 meta,
178 "#[{}({} = ...)] must exist as a string",
179 self.meta_name(),
180 key
181 )
182 };
183 Some(lit.value())
184 } else {
185 None
186 };
187 Ok(value)
188 }
189
190 pub fn _optional_path(&self, key: &str) -> Result<Option<syn::Path>> {
191 let value = if let Some((_, meta)) = self.meta_map.get(key) {

Callers 9

impl_pyclassFunction · 0.80
method_nameMethod · 0.80
getset_nameMethod · 0.80
member_kindMethod · 0.80
simple_nameMethod · 0.80
optional_nameMethod · 0.80
ctx_nameMethod · 0.80
metaclassMethod · 0.80
impl_attrsMethod · 0.80

Calls 3

SomeClass · 0.50
getMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected