Skip to content

Commit 177f38f

Browse files
[ffe] Use cast instead of deprecated downcast
1 parent 6c16ac2 commit 177f38f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

datadog-ffe/src/rules_based/attributes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ mod pyo3_impl {
8787

8888
#[inline]
8989
fn extract(value: Borrowed<'a, 'py, PyAny>) -> PyResult<Self> {
90-
if let Ok(s) = value.downcast::<PyString>() {
90+
if let Ok(s) = value.cast::<PyString>() {
9191
return Ok(Attribute(AttributeImpl::String(s.to_cow()?.into())));
9292
}
9393
// In Python, Bool inherits from Int, so it must be checked first here.
94-
if let Ok(s) = value.downcast::<PyBool>() {
94+
if let Ok(s) = value.cast::<PyBool>() {
9595
return Ok(Attribute(AttributeImpl::Boolean(s.is_true())));
9696
}
97-
if let Ok(s) = value.downcast::<PyFloat>() {
97+
if let Ok(s) = value.cast::<PyFloat>() {
9898
return Ok(Attribute(AttributeImpl::Number(s.value())));
9999
}
100-
if let Ok(s) = value.downcast::<PyInt>() {
100+
if let Ok(s) = value.cast::<PyInt>() {
101101
return Ok(Attribute(AttributeImpl::Number(s.extract::<f64>()?)));
102102
}
103103
if value.is_none() {

datadog-ffe/src/rules_based/eval/evaluation_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ mod pyo3_impl {
7777
fn extract(value: Borrowed<'a, 'py, PyAny>) -> PyResult<Self> {
7878
let py = value.py();
7979

80-
let (targeting_key, attributes) = if let Ok(dict) = value.downcast::<PyDict>() {
80+
let (targeting_key, attributes) = if let Ok(dict) = value.cast::<PyDict>() {
8181
(
8282
dict.get_item(intern!(py, "targeting_key"))?,
8383
dict.get_item(intern!(py, "attributes"))?,

datadog-ffe/src/rules_based/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ mod pyo3_impl {
125125

126126
#[inline]
127127
fn extract(value: Borrowed<'a, 'py, PyAny>) -> PyResult<Self> {
128-
let s = value.downcast::<PyString>()?;
128+
let s = value.cast::<PyString>()?;
129129
Ok(Str::from(s.to_cow()?))
130130
}
131131
}

0 commit comments

Comments
 (0)