From cb8cc812afdbf7703376cb00f870091208bb576b Mon Sep 17 00:00:00 2001 From: Ada Bohm Date: Sun, 25 Jan 2026 11:10:13 +0100 Subject: [PATCH 1/3] Version changed to v0.22.0 --- CHANGELOG.md | 4 ++-- Cargo.lock | 2 +- nelsie/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3a0b9b..143e41d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ -# Unreleased +# v0.22.0 * When strip=True in code/text, then text steps line are rstripped * "typst" extension for writing mathematical expressions -* Migrate to parle 0.7 +* Migrate to parley 0.7 # v0.21.2 diff --git a/Cargo.lock b/Cargo.lock index 887515b..5400b61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -714,7 +714,7 @@ dependencies = [ [[package]] name = "nelsie" -version = "0.20.2" +version = "0.22.0" dependencies = [ "imagesize 0.14.0", "itertools", diff --git a/nelsie/Cargo.toml b/nelsie/Cargo.toml index 5e30129..f57bd7b 100644 --- a/nelsie/Cargo.toml +++ b/nelsie/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nelsie" -version = "0.20.2" +version = "0.22.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 4f5d13b41f44a7be22ef6cf8e78bbf0fc3081656 Mon Sep 17 00:00:00 2001 From: Ada Bohm Date: Sun, 25 Jan 2026 11:18:03 +0100 Subject: [PATCH 2/3] zip dep updated --- Cargo.lock | 36 +++++++++++------------------------- nelsie/Cargo.toml | 4 ++-- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5400b61..3e4542e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,15 +23,6 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" -[[package]] -name = "arbitrary" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" -dependencies = [ - "derive_arbitrary", -] - [[package]] name = "arrayref" version = "0.3.9" @@ -166,9 +157,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" dependencies = [ "cfg-if", ] @@ -213,17 +204,6 @@ dependencies = [ "powerfmt", ] -[[package]] -name = "derive_arbitrary" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "displaydoc" version = "0.2.5" @@ -1484,6 +1464,12 @@ dependencies = [ "core_maths", ] +[[package]] +name = "typed-path" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e43ffa54726cdc9ea78392023ffe9fe9cf9ac779e1c6fcb0d23f9862e3879d20" + [[package]] name = "unicode-bidi" version = "0.3.18" @@ -1975,15 +1961,15 @@ dependencies = [ [[package]] name = "zip" -version = "4.6.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034aa6c54f654df20e7dc3713bc51705c12f280748fb6d7f40f87c696623e34" +checksum = "c42e33efc22a0650c311c2ef19115ce232583abbe80850bc8b66509ebef02de0" dependencies = [ - "arbitrary", "crc32fast", "flate2", "indexmap", "memchr", + "typed-path", "zopfli", ] diff --git a/nelsie/Cargo.toml b/nelsie/Cargo.toml index f57bd7b..9c1c5c5 100644 --- a/nelsie/Cargo.toml +++ b/nelsie/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "nelsie" version = "0.22.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] @@ -19,5 +19,5 @@ pyo3 = { version = "0.26", features = ["abi3-py311", "extension-module"] } itertools = "0.14" strict-num = "*" imagesize = { version = "0.14", default-features = false, features = ["jpeg", "png"] } -zip = { version = "4.6", default-features = false, features = ["deflate"] } +zip = { version = "7.2", default-features = false, features = ["deflate"] } notify = "8" From b160d3a4905f89deab53f266289a4f8b21ab1e97 Mon Sep 17 00:00:00 2001 From: Ada Bohm Date: Sun, 25 Jan 2026 11:31:20 +0100 Subject: [PATCH 3/3] Migrated to PyO3 v0.27 --- Cargo.lock | 20 ++++++------ nelsie/Cargo.toml | 2 +- nelsie/src/common/steps.rs | 13 +++++--- nelsie/src/pyinterface/check.rs | 10 +++--- nelsie/src/pyinterface/common.rs | 8 ++--- nelsie/src/pyinterface/extract.rs | 47 +++++++++++++++------------- nelsie/src/pyinterface/image.rs | 10 +++--- nelsie/src/pyinterface/layoutexpr.rs | 10 +++--- nelsie/src/pyinterface/parsers.rs | 2 +- nelsie/src/pyinterface/rendering.rs | 4 +-- nelsie/src/pyinterface/resources.rs | 2 +- nelsie/src/pyinterface/shapes.rs | 7 +++-- nelsie/src/pyinterface/text.rs | 8 ++--- nelsie/src/pyinterface/watch.rs | 2 +- 14 files changed, 78 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e4542e..1f17b75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -885,9 +885,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba0117f4212101ee6544044dae45abe1083d30ce7b29c4b5cbdfa2354e07383" +checksum = "ab53c047fcd1a1d2a8820fe84f05d6be69e9526be40cb03b73f86b6b03e6d87d" dependencies = [ "indoc", "libc", @@ -902,18 +902,18 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fc6ddaf24947d12a9aa31ac65431fb1b851b8f4365426e182901eabfb87df5f" +checksum = "b455933107de8642b4487ed26d912c2d899dec6114884214a0b3bb3be9261ea6" dependencies = [ "target-lexicon", ] [[package]] name = "pyo3-ffi" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "025474d3928738efb38ac36d4744a74a400c901c7596199e20e45d98eb194105" +checksum = "1c85c9cbfaddf651b1221594209aed57e9e5cff63c4d11d1feead529b872a089" dependencies = [ "libc", "pyo3-build-config", @@ -921,9 +921,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e64eb489f22fe1c95911b77c44cc41e7c19f3082fc81cce90f657cdc42ffded" +checksum = "0a5b10c9bf9888125d917fb4d2ca2d25c8df94c7ab5a52e13313a07e050a3b02" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -933,9 +933,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "100246c0ecf400b475341b8455a9213344569af29a3c841d29270e53102e0fcf" +checksum = "03b51720d314836e53327f5871d4c0cfb4fb37cc2c4a11cc71907a86342c40f9" dependencies = [ "heck", "proc-macro2", diff --git a/nelsie/Cargo.toml b/nelsie/Cargo.toml index 9c1c5c5..f3e9459 100644 --- a/nelsie/Cargo.toml +++ b/nelsie/Cargo.toml @@ -15,7 +15,7 @@ thiserror = { workspace = true } xmltree = { workspace = true } smallvec = { workspace = true } -pyo3 = { version = "0.26", features = ["abi3-py311", "extension-module"] } +pyo3 = { version = "0.27", features = ["abi3-py311", "extension-module"] } itertools = "0.14" strict-num = "*" imagesize = { version = "0.14", default-features = false, features = ["jpeg", "png"] } diff --git a/nelsie/src/common/steps.rs b/nelsie/src/common/steps.rs index 128539f..7f1bb45 100644 --- a/nelsie/src/common/steps.rs +++ b/nelsie/src/common/steps.rs @@ -1,7 +1,9 @@ use pyo3::exceptions::PyException; -use pyo3::types::{PyAnyMethods, PyTuple}; -use pyo3::{Bound, FromPyObject, IntoPyObject, IntoPyObjectExt, PyAny, PyErr, PyResult, Python}; -use smallvec::{smallvec, SmallVec}; +use pyo3::types::PyTuple; +use pyo3::{ + Borrowed, Bound, FromPyObject, IntoPyObject, IntoPyObjectExt, PyAny, PyErr, PyResult, Python, +}; +use smallvec::{SmallVec, smallvec}; use std::cmp::Ordering; use std::fmt::{Debug, Display, Formatter}; @@ -94,8 +96,9 @@ impl<'py> IntoPyObject<'py> for &Step { } } -impl<'py> FromPyObject<'py> for Step { - fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for Step { + type Error = PyErr; + fn extract(ob: Borrowed<'_, 'py, PyAny>) -> PyResult { if let Ok(v) = ob.extract::() { return Ok(Step::from_int(v)); } diff --git a/nelsie/src/pyinterface/check.rs b/nelsie/src/pyinterface/check.rs index f942bcd..e706389 100644 --- a/nelsie/src/pyinterface/check.rs +++ b/nelsie/src/pyinterface/check.rs @@ -1,15 +1,15 @@ use pyo3::exceptions::PyException; use pyo3::types::PyAnyMethods; -use pyo3::{pyfunction, Bound, PyAny, PyResult}; +use pyo3::{Bound, PyAny, PyResult, pyfunction}; use std::str::FromStr; /// Formats the sum of two numbers as string. #[pyfunction] pub(crate) fn check_color<'py>(obj: &Bound<'py, PyAny>) -> PyResult<()> { - if let Ok(s) = obj.extract::<&str>() { - if renderer::Color::from_str(s).is_ok() { - return Ok(()); - } + if let Ok(s) = obj.extract::<&str>() + && renderer::Color::from_str(s).is_ok() + { + return Ok(()); } Err(PyException::new_err(format!("Invalid color: '{}'", obj))) } diff --git a/nelsie/src/pyinterface/common.rs b/nelsie/src/pyinterface/common.rs index 7de7345..0c20652 100644 --- a/nelsie/src/pyinterface/common.rs +++ b/nelsie/src/pyinterface/common.rs @@ -1,12 +1,12 @@ -use pyo3::types::PyAnyMethods; -use pyo3::{Bound, FromPyObject, PyAny, PyResult}; +use pyo3::{Borrowed, FromPyObject, PyAny, PyErr, PyResult}; use renderer::Color; use std::str::FromStr; pub(crate) struct PyColor(Color); -impl<'py> FromPyObject<'py> for PyColor { - fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyColor { + type Error = PyErr; + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> PyResult { let s: &str = obj.extract()?; Ok(PyColor(Color::from_str(s).map_err(crate::Error::from)?)) } diff --git a/nelsie/src/pyinterface/extract.rs b/nelsie/src/pyinterface/extract.rs index 8622c1d..9f3eaca 100644 --- a/nelsie/src/pyinterface/extract.rs +++ b/nelsie/src/pyinterface/extract.rs @@ -7,7 +7,7 @@ use crate::pyinterface::text::PyTextContent; use pyo3::exceptions::PyValueError; use pyo3::prelude::PyAnyMethods; use pyo3::types::PyList; -use pyo3::{intern, Bound, FromPyObject, PyAny, PyResult}; +use pyo3::{Borrowed, Bound, FromPyObject, PyAny, PyErr, PyResult, intern}; use renderer::taffy::style_helpers::{ FromFlex, FromLength, FromPercent, TaffyGridLine, TaffyGridSpan, }; @@ -29,8 +29,9 @@ struct PyPage<'py> { struct PyLengthOrExpr(LengthOrExpr); -impl<'py> FromPyObject<'py> for PyLengthOrExpr { - fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyLengthOrExpr { + type Error = PyErr; + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> PyResult { Ok(PyLengthOrExpr(if let Ok(value) = obj.extract::() { LengthOrExpr::points(value) } else if let Ok(value) = obj.extract::<&str>() { @@ -43,8 +44,9 @@ impl<'py> FromPyObject<'py> for PyLengthOrExpr { struct PyLength(Length); -impl<'py> FromPyObject<'py> for PyLength { - fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyLength { + type Error = PyErr; + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> PyResult { Ok(PyLength(if let Ok(value) = obj.extract::() { Length::Points { value } } else if let Ok(value) = obj.extract::<&str>() { @@ -57,8 +59,9 @@ impl<'py> FromPyObject<'py> for PyLength { struct PyLengthOrAuto(LengthOrAuto); -impl<'py> FromPyObject<'py> for PyLengthOrAuto { - fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyLengthOrAuto { + type Error = PyErr; + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> PyResult { Ok(PyLengthOrAuto(if let Ok(value) = obj.extract::() { LengthOrAuto::Length(Length::Points { value }) } else if let Ok(value) = obj.extract::<&str>() { @@ -71,8 +74,9 @@ impl<'py> FromPyObject<'py> for PyLengthOrAuto { struct PyAlignItems(AlignItems); -impl<'py> FromPyObject<'py> for PyAlignItems { - fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyAlignItems { + type Error = PyErr; + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> PyResult { let s = obj.extract::<&str>()?; Ok(PyAlignItems(match s { "start" => AlignItems::Start, @@ -95,8 +99,9 @@ impl From for AlignItems { struct PyAlignContent(AlignContent); -impl<'py> FromPyObject<'py> for PyAlignContent { - fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyAlignContent { + type Error = PyErr; + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> PyResult { let s = obj.extract::<&str>()?; Ok(PyAlignContent(match s { "start" => AlignContent::Start, @@ -121,8 +126,9 @@ impl From for AlignContent { struct PyGridTemplateItem(NonRepeatedTrackSizingFunction); -impl<'py> FromPyObject<'py> for PyGridTemplateItem { - fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyGridTemplateItem { + type Error = PyErr; + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> PyResult { Ok(PyGridTemplateItem( if let Ok(value) = obj.extract::() { NonRepeatedTrackSizingFunction::from_length(value) @@ -156,7 +162,7 @@ impl From for NonRepeatedTrackSizingFunction { struct PyGridLinePlacement(Line); -fn parse_grid_placement_item(obj: &Bound) -> PyResult { +fn parse_grid_placement_item(obj: Borrowed<'_, '_, PyAny>) -> PyResult { if obj.is_none() { return Ok(GridPlacement::Auto); } @@ -180,20 +186,19 @@ fn parse_grid_placement_item(obj: &Bound) -> PyResult { } } -impl<'py> FromPyObject<'py> for PyGridLinePlacement { - fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyGridLinePlacement { + type Error = PyErr; + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> PyResult { if let Ok(value) = parse_grid_placement_item(obj) { return Ok(PyGridLinePlacement(Line { start: value, end: GridPlacement::Auto, })); } else if let Ok((value1, value2)) = obj.extract::<(Bound<'py, PyAny>, Bound<'py, PyAny>)>() + && let Ok(start) = parse_grid_placement_item(value1.as_borrowed()) + && let Ok(end) = parse_grid_placement_item(value2.as_borrowed()) { - if let Ok(start) = parse_grid_placement_item(&value1) { - if let Ok(end) = parse_grid_placement_item(&value2) { - return Ok(PyGridLinePlacement(Line { start, end })); - } - } + return Ok(PyGridLinePlacement(Line { start, end })); } Err(PyValueError::new_err("Invalid grid placement")) } diff --git a/nelsie/src/pyinterface/image.rs b/nelsie/src/pyinterface/image.rs index f5eb516..04bcba0 100644 --- a/nelsie/src/pyinterface/image.rs +++ b/nelsie/src/pyinterface/image.rs @@ -1,11 +1,12 @@ use super::ora::create_ora; -use crate::common::steps::{bool_at_step, Step}; +use crate::common::steps::{Step, bool_at_step}; use crate::parsers::steps::parse_bool_steps; use itertools::Itertools; use pyo3::exceptions::{PyException, PyValueError}; use pyo3::types::PyAnyMethods; use pyo3::{ - pyclass, pyfunction, pymethods, Bound, FromPyObject, IntoPyObject, PyAny, PyResult, Python, + Borrowed, Bound, FromPyObject, IntoPyObject, PyAny, PyErr, PyResult, Python, pyclass, + pyfunction, pymethods, }; use renderer::{InMemoryBinImage, InMemorySvgImage, Rectangle}; use resvg::usvg::roxmltree; @@ -292,8 +293,9 @@ pub(crate) enum PyImageFormat { Svg, } -impl<'py> FromPyObject<'py> for PyImageFormat { - fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyImageFormat { + type Error = PyErr; + fn extract(ob: Borrowed<'_, 'py, PyAny>) -> PyResult { let s: &str = ob.extract()?; Ok(match s { "png" => Self::Png, diff --git a/nelsie/src/pyinterface/layoutexpr.rs b/nelsie/src/pyinterface/layoutexpr.rs index 0372f21..805a48b 100644 --- a/nelsie/src/pyinterface/layoutexpr.rs +++ b/nelsie/src/pyinterface/layoutexpr.rs @@ -1,6 +1,6 @@ use pyo3::exceptions::PyValueError; use pyo3::types::PyAnyMethods; -use pyo3::{intern, Bound, PyAny, PyResult}; +use pyo3::{Borrowed, Bound, PyAny, PyResult, intern}; use renderer::{InlineId, LayoutExpr, NodeId}; // #[derive(Debug)] @@ -21,7 +21,7 @@ use renderer::{InlineId, LayoutExpr, NodeId}; // } // } -pub(crate) fn extract_layout_expr(obj: &Bound) -> PyResult { +pub(crate) fn extract_layout_expr(obj: Borrowed<'_, '_, PyAny>) -> PyResult { if let Ok(value) = obj.extract() { return Ok(LayoutExpr::const_value(value)); } @@ -35,8 +35,8 @@ pub(crate) fn extract_layout_expr(obj: &Bound) -> PyResult { let name: &str = op.extract()?; match name { "+" | "-" | "*" => { - let expr_a = extract_layout_expr(&v0)?; - let expr_b = extract_layout_expr(&v1)?; + let expr_a = extract_layout_expr(v0.as_borrowed())?; + let expr_b = extract_layout_expr(v1.as_borrowed())?; Ok(match name { "+" => LayoutExpr::add(expr_a, expr_b), "-" => LayoutExpr::sub(expr_a, expr_b), @@ -97,7 +97,7 @@ pub(crate) fn extract_layout_expr(obj: &Bound) -> PyResult { "max" => Ok(LayoutExpr::max({ let v: Vec> = v0.extract()?; v.into_iter() - .map(|obj| extract_layout_expr(&obj)) + .map(|obj| extract_layout_expr(obj.as_borrowed())) .collect::>()? })), _ => Err(PyValueError::new_err("Invalid expression")), diff --git a/nelsie/src/pyinterface/parsers.rs b/nelsie/src/pyinterface/parsers.rs index 626cd09..ff9b71b 100644 --- a/nelsie/src/pyinterface/parsers.rs +++ b/nelsie/src/pyinterface/parsers.rs @@ -1,5 +1,5 @@ use pyo3::types::{PyDict, PyDictMethods, PyList}; -use pyo3::{pyfunction, Bound, IntoPyObject, IntoPyObjectExt, PyAny, PyResult, Python}; +use pyo3::{Bound, IntoPyObject, IntoPyObjectExt, PyAny, PyResult, Python, pyfunction}; use std::collections::BTreeMap; // fn step_to_pyobj<'py>(py: Python<'py>, step: &Step) -> PyResult> { diff --git a/nelsie/src/pyinterface/rendering.rs b/nelsie/src/pyinterface/rendering.rs index 9fdceff..ca78e31 100644 --- a/nelsie/src/pyinterface/rendering.rs +++ b/nelsie/src/pyinterface/rendering.rs @@ -2,7 +2,7 @@ use crate::pyinterface::extract::obj_to_page; use crate::pyinterface::resources::Resources; use pyo3::exceptions::PyException; use pyo3::types::{PyDict, PyDictMethods, PyList}; -use pyo3::{pyfunction, Bound, IntoPyObjectExt, PyAny, PyResult, Python}; +use pyo3::{Bound, IntoPyObjectExt, PyAny, PyResult, Python, pyfunction}; use renderer::{Document, PageLayout, Register, RenderingOptions}; use std::collections::HashMap; @@ -128,7 +128,7 @@ fn run_rendering( _ => { return Err(PyException::new_err(format!( "Invalid output format: {format}" - ))) + ))); } }) } diff --git a/nelsie/src/pyinterface/resources.rs b/nelsie/src/pyinterface/resources.rs index 0d44223..ad6f06a 100644 --- a/nelsie/src/pyinterface/resources.rs +++ b/nelsie/src/pyinterface/resources.rs @@ -1,5 +1,5 @@ use itertools::Itertools; -use pyo3::{pyclass, pymethods, PyResult}; +use pyo3::{PyResult, pyclass, pymethods}; use std::path::Path; #[pyclass] diff --git a/nelsie/src/pyinterface/shapes.rs b/nelsie/src/pyinterface/shapes.rs index 5ce8ba0..335bfe0 100644 --- a/nelsie/src/pyinterface/shapes.rs +++ b/nelsie/src/pyinterface/shapes.rs @@ -3,7 +3,7 @@ use crate::pyinterface::common::PyColor; use crate::pyinterface::layoutexpr::extract_layout_expr; use pyo3::exceptions::PyValueError; use pyo3::types::{PyAnyMethods, PyIterator, PyList}; -use pyo3::{Bound, FromPyObject, PyAny, PyResult}; +use pyo3::{Borrowed, Bound, FromPyObject, PyAny, PyErr, PyResult}; use renderer::Path; use renderer::{Arrow, FillAndStroke, LayoutExpr, Length, PathPart, Shape, ShapeRect, Stroke}; use std::marker::PhantomData; @@ -41,8 +41,9 @@ pub(crate) struct PyPosition { _dim: PhantomData, } -impl<'py, D: Dimension> FromPyObject<'py> for PyPosition { - fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { +impl<'py, D: Dimension> FromPyObject<'_, 'py> for PyPosition { + type Error = PyErr; + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> PyResult { Ok(PyPosition { expr: if let Ok(value) = obj.extract::() { D::parent_pos(value) diff --git a/nelsie/src/pyinterface/text.rs b/nelsie/src/pyinterface/text.rs index d2d6067..f544d10 100644 --- a/nelsie/src/pyinterface/text.rs +++ b/nelsie/src/pyinterface/text.rs @@ -1,7 +1,6 @@ use crate::pyinterface::common::PyColor; use pyo3::exceptions::PyValueError; -use pyo3::types::PyAnyMethods; -use pyo3::{Bound, FromPyObject, PyAny, PyErr, PyResult}; +use pyo3::{Borrowed, FromPyObject, PyAny, PyErr, PyResult}; use renderer::{ FontStretch, ParsingChars, SyntaxHighlightSettings, Text, TextAlign, TextStyle, TextStyling, }; @@ -84,8 +83,9 @@ impl TryFrom for TextStyle { pub(crate) struct PyTextAlign(TextAlign); -impl<'py> FromPyObject<'py> for PyTextAlign { - fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { +impl<'py> FromPyObject<'_, 'py> for PyTextAlign { + type Error = PyErr; + fn extract(ob: Borrowed<'_, 'py, PyAny>) -> PyResult { let s: &str = ob.extract()?; Ok(PyTextAlign(match s { "start" => TextAlign::Start, diff --git a/nelsie/src/pyinterface/watch.rs b/nelsie/src/pyinterface/watch.rs index df0ee3c..b1c5bb4 100644 --- a/nelsie/src/pyinterface/watch.rs +++ b/nelsie/src/pyinterface/watch.rs @@ -1,6 +1,6 @@ use notify::{Config, EventKind, RecommendedWatcher, RecursiveMode, Watcher}; use pyo3::exceptions::PyException; -use pyo3::{pyfunction, PyResult, Python}; +use pyo3::{PyResult, Python, pyfunction}; use std::thread::sleep; use std::time::Duration;