Get as string from dump(:) in Swift

In Swift, dump function is very helpful during debugging.

However, the default behavior of dump prints to console directly with stdout.

In order to get as string from text that dump printed, use text-stream argument dump has.

public func dumpString<T>(_ object: T) -> String {
  var dumpString = ""
  Swift.dump(object, to: &dumpString, name: "", indent: 2, maxDepth: .max, maxItems: .max)
  return dumpString
}