0

I'm reading this piece of code:

pub fn ip_addrs<T>(mut self, ip_addrs: T) -> Self
        where T: Into<ManagedSlice<'c, IpCidr>>
    {

T must be of type Into. However, I cannot understand what Into does by reading its definition. Can somebody explain?

Guerlando OCs
  • 162
  • 1
  • 29
  • 87

1 Answers1

2

From and Into are two traits specifying protocols for converting between types (without failure). That is if A implements Into<B>, you can always convert an A to a B and it will never fail.

Here it's used such that you can give this function anything which is convertible to a ManagedSlice.

user2722968
  • 10,969
  • 2
  • 32
  • 55
Masklinn
  • 23,560
  • 2
  • 21
  • 39