fix: add life support to handles cast to string_view (#6092)

* Fix handling of string_view to prevent GC'ing strings before they are used.

* style: pre-commit fixes

* Update cast.h

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
3 files changed