refinement icon indicating copy to clipboard operation
refinement copied to clipboard

`Refinement.to_inner` misleading name and documentation

Open koutheir opened this issue 3 years ago • 0 comments

The implementation of the method Refinement.to_inner() has two problems:

  1. It implicitly performs a (potentially expensive) self.clone(), and
  2. It provides a clone of the stored value.

Currently, the documentation of the method says:

Retrieve the underlying value without consuming self.

First, the returned value is not the underlying value, but a clone of that value. Second, the inner value is cloned, without any indication of that happening, neither in the name nor in the documentation.

I suggest renaming the method to clone_inner(), and changing the documentation to:

Returns a clone of the underlying value without consuming self.

koutheir avatar Feb 24 '23 14:02 koutheir