We're talking copyright here, not patents. If I read copyrighted C code, and rewrite it in Rust, I don't think a copyright claim can touch you, no matter how similar they are.
Note well: IANAL. This is my understanding of copyright law, not legal advice.
IANAL also. But it's important to distinguish a copy (which is just more or less copying what you read in C) vs a derivative work (a work that could not have been done or would have been done noticeably differently in the absence of the parent work existing). Just because you read Harry Potter 5 years ago and only now bother to write a fanfic in French using your memory of that world as a base, maybe keeping most names or subtly changing them a bit, does not mean your new work isn't derivative. It probably shouldn't be derivative given how much of our creative culture is remix upon remix, but hey, that's a much more extreme position that gets close to abolishing copyright entirely.
Code is just tricky though and metaphors for books and other things often break down easily... API / module substitution copyright seems silly, but maybe only to people who understand programming or who can grasp the metaphor that copyrighting an interface is like saying any book that uses numbered chapters (instead of custom named chapters) is a derivative work of the first book that used numbered chapters. Some code "could be but one way", naming included / irrelevant (I think a lot of SO code is like this, there are very few ways to glue together certain bits of code to do small thing X in context C), some of it is more like performance art, some of it is just almost pure math, and some of it works as a whole to solve one particularly hard problem which in itself has business value, just as music has business value by solving the problem of being appealing to listen to so that people buy it. Copyright law seems ill-equipped to handle it. Strategically though, I'd go with what the lawyers advise -- a lawsuit that I win can still be more costly than just playing it safe to begin with.
Note well: IANAL. This is my understanding of copyright law, not legal advice.