When cow is a Cow::Owned, cow.to_owned() returns a Cow::Owned, which leads to infinite recursion. Extract the owned or borrowed values from the cow to ensure progress is made in either case.