mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
21 lines
639 B
Rust
21 lines
639 B
Rust
use crate::source_code::SourceLocation;
|
|
|
|
// pub(crate) fn new_location_error(
|
|
// index: usize,
|
|
// field: &str,
|
|
// vm: &VirtualMachine,
|
|
// ) -> PyRef<PyBaseException> {
|
|
// vm.new_value_error(format!("value {index} is too large for location {field}"))
|
|
// }
|
|
|
|
pub(crate) struct AtLocation<'a>(pub Option<&'a SourceLocation>);
|
|
|
|
impl std::fmt::Display for AtLocation<'_> {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
let (row, column) = self
|
|
.0
|
|
.map_or((0, 0), |l| (l.row.to_usize(), l.column.to_usize()));
|
|
write!(f, " at line {row} column {column}",)
|
|
}
|
|
}
|