How should I name two variant of methods for chaining?

I want to provide two variants of method for chaining.

  1. fn set_t(&mut self, &T) -> &mut self
  2. fn set_t(self, &T) -> self

What should I name these methods to avoid confusion? My first idea was set_t, set_t_owned but I think the name _owned might be confused with parameter(T).

1 Like

In generally expect version 2 to be named with_t

5 Likes

so it would be set_t(&mut self) and with_t(self)?

Yes, they would be:

fn set_t(&mut self, t: T) -> &mut Self

fn with_t(self, t: T) -> Self
2 Likes