Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add pretty print to list and tuple
  • Loading branch information
yodalee committed Jul 12, 2018
commit 9f18ccd65790cbcfe88a9f0b4556cf15e644c2a4
14 changes: 12 additions & 2 deletions vm/src/pyobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,18 @@ impl PyObject {
match self.kind {
PyObjectKind::String { ref value } => value.clone(),
PyObjectKind::Integer { ref value } => format!("{:?}", value),
PyObjectKind::List { ref elements } => format!("{:?}", elements),
PyObjectKind::Tuple { ref elements } => format!("{:?}", elements),
PyObjectKind::List { ref elements } => {
format!("[{}]", elements.iter()
.map(|elem| elem.borrow_mut().str())
.collect::<Vec<_>>()
.join(", "))
}
PyObjectKind::Tuple { ref elements } => {
format!("{{{}}}", elements.iter()
.map(|elem| elem.borrow_mut().str())
.collect::<Vec<_>>()
.join(", "))
}
PyObjectKind::None => String::from("None"),
_ => {
println!("Not impl {:?}", self);
Expand Down