All straight line functions except constant functions are one-to- one functions.
A function is one-to-one, if every horizontal line intersects the curve at most at one point.
If any horizontal line cuts the graph of the function at more than one point, it means that there will be at least two elements in the domain which have the same image.
For all straight line functions except constant functions, we would not be able to find even a single horizontal line that would cut the curve at more than one point.
A constant function can never be one-to-one as every element of the domain would be mapped to a single point.