Initialize library with given "Serial" port

Hi,
I’m just trying to write my first library. To be flexible I would like supply the “Serial” port during initialization like:

void setup() {
    Serial1.begin(9600);
    Library.begin(Serial1);
}

Is this somehow possible? Can anyone give me an example, where such a solution is already implemented? Or is there a better way to solve this issue?

Thank you!

It is possible to pass a reference

void Library::test(USARTSerial& x)
{
    x.println("test");
}

If you also want to support USBSerial your library could also add an overload for that

void Library::test(USBSerial& x)
{
    x.println("test");
}