Skip to content

Commit cce206c

Browse files
committed
adapt PyExact
1 parent 6d3589d commit cce206c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

vm/src/builtins/str.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
AsMapping, AsSequence, Comparable, Constructor, Hashable, IterNext, IterNextIterable,
1717
Iterable, PyComparisonOp, Unconstructible,
1818
},
19-
AsObject, Context, Py, PyObject, PyObjectRef, PyPayload, PyRef, PyRefExact, PyResult,
19+
AsObject, Context, Py, PyExact, PyObject, PyObjectRef, PyPayload, PyRef, PyRefExact, PyResult,
2020
TryFromBorrowedObject, VirtualMachine,
2121
};
2222
use ascii::{AsciiStr, AsciiString};
@@ -1534,6 +1534,12 @@ impl AsRef<str> for PyRefExact<PyStr> {
15341534
}
15351535
}
15361536

1537+
impl AsRef<str> for PyExact<PyStr> {
1538+
fn as_ref(&self) -> &str {
1539+
self.as_str()
1540+
}
1541+
}
1542+
15371543
#[cfg(test)]
15381544
mod tests {
15391545
use super::*;

vm/src/intern.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{
22
builtins::{PyStr, PyTypeRef},
33
common::lock::PyRwLock,
44
convert::ToPyObject,
5-
Py, PyObject, PyObjectRef, PyRef, PyRefExact,
5+
Py, PyExact, PyObject, PyObjectRef, PyRef, PyRefExact,
66
};
77
use std::{
88
borrow::{Borrow, ToOwned},
@@ -199,7 +199,7 @@ impl std::fmt::Display for PyStrInterned {
199199
mod sealed {
200200
use crate::{
201201
builtins::PyStr,
202-
object::{Py, PyRefExact},
202+
object::{Py, PyExact, PyRefExact},
203203
};
204204

205205
pub trait SealedInternable {}
@@ -211,7 +211,7 @@ mod sealed {
211211
pub trait SealedMaybeInterned {}
212212

213213
impl SealedMaybeInterned for str {}
214-
impl SealedMaybeInterned for PyRefExact<PyStr> {}
214+
impl SealedMaybeInterned for PyExact<PyStr> {}
215215
impl SealedMaybeInterned for Py<PyStr> {}
216216
}
217217

@@ -259,6 +259,13 @@ impl MaybeInterned for str {
259259
}
260260
}
261261

262+
impl MaybeInterned for PyExact<PyStr> {
263+
#[inline(always)]
264+
fn as_interned(&self) -> Option<&'static PyStrInterned> {
265+
None
266+
}
267+
}
268+
262269
impl MaybeInterned for Py<PyStr> {
263270
#[inline(always)]
264271
fn as_interned(&self) -> Option<&'static PyStrInterned> {

0 commit comments

Comments
 (0)