AsDInt attempts to retrieve a DInt from an Expr, returning a DInt and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions wherever a *DInt wrapped by a *DOidWrapper is possible.
(e Expr)
| 625 | // be used instead of direct type assertions wherever a *DInt wrapped by a |
| 626 | // *DOidWrapper is possible. |
| 627 | func AsDInt(e Expr) (DInt, bool) { |
| 628 | switch t := e.(type) { |
| 629 | case *DInt: |
| 630 | return *t, true |
| 631 | case *DOidWrapper: |
| 632 | return AsDInt(t.Wrapped) |
| 633 | } |
| 634 | return 0, false |
| 635 | } |
| 636 | |
| 637 | // MustBeDInt attempts to retrieve a DInt from an Expr, panicking if the |
| 638 | // assertion fails. |
no outgoing calls
no test coverage detected
searching dependent graphs…