Skip to content

Commit 84d47d2

Browse files
Rename to just Either
1 parent 3c15d89 commit 84d47d2

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

vm/src/obj/objrange.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use num_traits::{One, Signed, ToPrimitive, Zero};
77

88
use crate::function::{OptionalArg, PyFuncArgs};
99
use crate::pyobject::{
10-
Either2, PyContext, PyIteratorValue, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
10+
Either, PyContext, PyIteratorValue, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
1111
};
1212
use crate::vm::VirtualMachine;
1313

@@ -212,16 +212,16 @@ impl PyRangeRef {
212212
.into_ref_with_type(vm, cls)
213213
}
214214

215-
fn getitem(self, subscript: Either2<PyIntRef, PySliceRef>, vm: &VirtualMachine) -> PyResult {
215+
fn getitem(self, subscript: Either<PyIntRef, PySliceRef>, vm: &VirtualMachine) -> PyResult {
216216
match subscript {
217-
Either2::A(index) => {
217+
Either::A(index) => {
218218
if let Some(value) = self.get(index.value.clone()) {
219219
Ok(PyInt::new(value).into_ref(vm).into_object())
220220
} else {
221221
Err(vm.new_index_error("range object index out of range".to_string()))
222222
}
223223
}
224-
Either2::B(slice) => {
224+
Either::B(slice) => {
225225
let new_start = if let Some(int) = slice.start.clone() {
226226
if let Some(i) = self.get(int) {
227227
i

vm/src/pyobject.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ impl<T: PyValue + 'static> PyObjectPayload for T {
12031203
}
12041204
}
12051205

1206-
pub enum Either2<A, B> {
1206+
pub enum Either<A, B> {
12071207
A(A),
12081208
B(B),
12091209
}
@@ -1216,28 +1216,28 @@ pub enum Either2<A, B> {
12161216
/// ```
12171217
/// use rustpython_vm::VirtualMachine;
12181218
/// use rustpython_vm::obj::{objstr::PyStringRef, objint::PyIntRef};
1219-
/// use rustpython_vm::pyobject::Either2;
1219+
/// use rustpython_vm::pyobject::Either;
12201220
///
1221-
/// fn do_something(arg: Either2<PyIntRef, PyStringRef>, vm: &VirtualMachine) {
1221+
/// fn do_something(arg: Either<PyIntRef, PyStringRef>, vm: &VirtualMachine) {
12221222
/// match arg {
1223-
/// Either2::A(int)=> {
1223+
/// Either::A(int)=> {
12241224
/// // do something with int
12251225
/// }
1226-
/// Either2::B(string) => {
1226+
/// Either::B(string) => {
12271227
/// // do something with string
12281228
/// }
12291229
/// }
12301230
/// }
12311231
/// ```
1232-
impl<A, B> TryFromObject for Either2<PyRef<A>, PyRef<B>>
1232+
impl<A, B> TryFromObject for Either<PyRef<A>, PyRef<B>>
12331233
where
12341234
A: PyValue,
12351235
B: PyValue,
12361236
{
12371237
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
12381238
obj.downcast::<A>()
1239-
.map(Either2::A)
1240-
.or_else(|obj| obj.clone().downcast::<B>().map(Either2::B))
1239+
.map(Either::A)
1240+
.or_else(|obj| obj.clone().downcast::<B>().map(Either::B))
12411241
.map_err(|obj| {
12421242
vm.new_type_error(format!(
12431243
"must be {} or {}, not {}",

0 commit comments

Comments
 (0)