Currently InvRef:contains_item() returns true if the item was found, and false otherwise. I suggest that this be augmented, so that it returns the index of the item (or 0 if it was not found).
Alternatively, to preserve backwards compatibility, there could be an InvRef:find_item() function.
This is useful when modifying item stacks that have wear and other data associated with them. For example, detecting if an item stack exists and has full durability.