Skip to content

Commit

Permalink
approve
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Oct 30, 2024
1 parent d8a68e9 commit 6db6f3b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cadence/20241010-stringer-interface.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
status: draft
status: approved
flip: 293
authors: Raymond Zhang ([email protected])
sponsor: Supun Setunga ([email protected])
updated: 2024-10-21
sponsor: Supun Setunga ([email protected])
updated: 2024-10-30
---

# FLIP 293: StructStringer Interface
Expand All @@ -12,7 +12,7 @@ updated: 2024-10-21

This FLIP proposes the addition of a struct interface `StructStringer` to Cadence, which all string-convertible structs will implement. Note that some languages distinguish between a "human-readable representation" and a "debug representation". The purpose of the `StructStringer` interface is to help with providing "human-readable representations" of `AnyStruct` and is separate from the "debug representation" which already exists.

One goal of this FLIP is to simplify the process for representing `AnyStruct` as a `String`. Secondly, a customizable `toString` will be useful for future string formatting such as string interpolation with this interface.
One goal of this FLIP is to simplify the process for representing `AnyStruct` as a `String`. Secondly, a customizable `toString` will be useful for future string formatting such as string interpolation with this interface.

## Motivation

Expand All @@ -35,7 +35,7 @@ access(all) fun toString(_ value: AnyStruct): String? {
...
}
```
With the proposed addition, the code could be simplified to
With the proposed addition, the code could be simplified to
```cadence
access(all) fun toString(_ value: AnyStruct): String? {
if let stringerValue = value as? {StructStringer} {
Expand All @@ -54,7 +54,7 @@ This will significantly streamline the process of converting `AnyStruct` values
The proposed interface is as follows

```cadence
access(all)
access(all)
struct interface StructStringer {
access(all)
view fun toString(): String
Expand Down

0 comments on commit 6db6f3b

Please sign in to comment.