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)
| 681 | // be used instead of direct type assertions wherever a *DInt wrapped by a |
| 682 | // *DOidWrapper is possible. |
| 683 | func AsDInt(e Expr) (DInt, bool) { |
| 684 | switch t := e.(type) { |
| 685 | case *DInt: |
| 686 | return *t, true |
| 687 | case *DOidWrapper: |
| 688 | return AsDInt(t.Wrapped) |
| 689 | } |
| 690 | return 0, false |
| 691 | } |
| 692 | |
| 693 | // MustBeDInt attempts to retrieve a DInt from an Expr, panicking if the |
| 694 | // assertion fails. |
no outgoing calls
no test coverage detected
searching dependent graphs…