BTW, to avoid the issue of unlocked bikes in the rack, we have locks that patrons (usually kids) can check out on their card while they're at the library.
Disclaimer: I'm a cynical person with a security-focused mindset who loves to analyze stuff like this. Most people aren't, so disregard me at will.
The problem isn't with letting them check out the locks. It's with letting them have the
keys.
You could obscure the key code, i guess, and... maybe only give them the keys when they need to *unlock* the bikes, but... it's difficult to see how you could prevent someone from having keys to all the library's locks within a week.