| 1 | fn fake_prompt[T](msg string, default ?T) string { |
| 2 | return build_prompt(msg, default) |
| 3 | } |
| 4 | |
| 5 | fn build_prompt[T](msg string, default ?T) string { |
| 6 | mut s := msg |
| 7 | if default != none { |
| 8 | s += ' [${default}]' |
| 9 | } |
| 10 | s += ': ' |
| 11 | return s |
| 12 | } |
| 13 | |
| 14 | fn test_main() { |
| 15 | p1 := fake_prompt[string]('hello', none) |
| 16 | p2 := fake_prompt[string]('hello', 'world') |
| 17 | assert p1 == 'hello: ' |
| 18 | assert p2 == 'hello [world]: ' |
| 19 | } |
| 20 |