AsDString attempts to retrieve a DString from an Expr, returning a DString and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions wherever a *DString wrapped by a *DOidWrapper is possible.
(e Expr)
| 1206 | // be used instead of direct type assertions wherever a *DString wrapped by a |
| 1207 | // *DOidWrapper is possible. |
| 1208 | func AsDString(e Expr) (DString, bool) { |
| 1209 | switch t := e.(type) { |
| 1210 | case *DString: |
| 1211 | return *t, true |
| 1212 | case *DOidWrapper: |
| 1213 | return AsDString(t.Wrapped) |
| 1214 | } |
| 1215 | return "", false |
| 1216 | } |
| 1217 | |
| 1218 | // MustBeDString attempts to retrieve a DString from an Expr, panicking if the |
| 1219 | // assertion fails. |
no outgoing calls
no test coverage detected
searching dependent graphs…