Replace explicit match with as_ref().(fixes #1870)

see #1870