12 lines
247 B
Python
12 lines
247 B
Python
from typing import TypeVar, Protocol
|
|
|
|
T = TypeVar('T') # <1>
|
|
|
|
class Repeatable(Protocol):
|
|
def __mul__(self: T, repeat_count: int) -> T: ... # <2>
|
|
|
|
RT = TypeVar('RT', bound=Repeatable) # <3>
|
|
|
|
def double(x: RT) -> RT: # <4>
|
|
return x * 2
|