From 7a52154d78ff85fe87647685885e9958a50cb42e Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 1 Sep 2013 23:36:25 -0400 Subject: repr: print functions as `fn()` --- src/libstd/repr.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 3e2c5773acc..381cd449695 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -551,13 +551,19 @@ impl<'self> TyVisitor for ReprVisitor<'self> { } fn visit_enter_fn(&mut self, _purity: uint, _proto: uint, - _n_inputs: uint, _retstyle: uint) -> bool { true } + _n_inputs: uint, _retstyle: uint) -> bool { + self.writer.write("fn(".as_bytes()); + true + } fn visit_fn_input(&mut self, _i: uint, _mode: uint, _inner: *TyDesc) -> bool { + // FIXME: #8917: should print out the parameter types here, separated by commas true } fn visit_fn_output(&mut self, _retstyle: uint, _inner: *TyDesc) -> bool { + self.writer.write(")".as_bytes()); + // FIXME: #8917: should print out the output type here, as `-> T` true } @@ -596,6 +602,7 @@ struct P {a: int, b: float} #[test] fn test_repr() { + use prelude::*; use str; use str::Str; use rt::io::Decorator; @@ -653,6 +660,8 @@ fn test_repr() { exact_test(&(10u64, ~"hello"), "(10u64, ~\"hello\")"); + exact_test(&(&println), "&fn()"); + struct Foo; exact_test(&(~[Foo, Foo]), "~[repr::test_repr::Foo, repr::test_repr::Foo]"); } -- cgit 1.4.1-3-g733a5