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

Method decimal

crates/stdlib/src/unicodedata.rs:276–290  ·  view source on GitHub ↗
(
            &self,
            character: PyStrRef,
            default: OptionalArg<PyObjectRef>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

274
275 #[pymethod]
276 fn decimal(
277 &self,
278 character: PyStrRef,
279 default: OptionalArg<PyObjectRef>,
280 vm: &VirtualMachine,
281 ) -> PyResult {
282 let ch = self.extract_char(character, vm)?.and_then(|c| c.to_char());
283 if let Some(ch) = ch
284 && ch.numeric_type() == Some(NumericType::Decimal)
285 && let Some(Number::Integer(n)) = ch.numeric_value()
286 {
287 return Ok(vm.ctx.new_int(n).into());
288 }
289 default.ok_or_else(|| vm.new_value_error("not a decimal"))
290 }
291
292 #[pymethod]
293 fn numeric(

Callers 3

test_decimalMethod · 0.80

Calls 5

extract_charMethod · 0.80
ok_or_elseMethod · 0.80
SomeClass · 0.50
to_charMethod · 0.45
new_intMethod · 0.45

Tested by 3

test_decimalMethod · 0.64