Skip to content

Commit

Permalink
clippy and newsfragment
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Feb 15, 2024
1 parent 775a0f4 commit 419ccb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions newsfragments/3802.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `PyBackedStr` and `PyBackedBytes`, as alternatives to `&str` and `&bytes` where a Python object owns the data.
5 changes: 4 additions & 1 deletion src/pybacked.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Contains types for working with Python objects that own the underlying data.
use std::{ops::Deref, ptr::NonNull};

use crate::{
Expand Down Expand Up @@ -39,7 +41,7 @@ impl TryFrom<Bound<'_, PyString>> for PyBackedStr {
}
#[cfg(not(any(Py_3_10, not(Py_LIMITED_API))))]
{
let bytes = string.encode_utf8()?;
let bytes = py_string.encode_utf8()?;
let b = bytes.as_bytes();
let data = NonNull::from(b);
let length = b.len();
Expand Down Expand Up @@ -67,6 +69,7 @@ pub struct PyBackedBytes {
data: NonNull<[u8]>,
}

#[allow(dead_code)]
enum PyBackedBytesStorage {
Python(Py<PyBytes>),
Rust(Box<[u8]>),
Expand Down

0 comments on commit 419ccb3

Please sign in to comment.