| ▲ | queoahfh 3 hours ago | |||||||
What a peculiar kind of rewrite. Rust: https://github.com/malisper/pgrust/blob/3646a73515a5e4ac7d0b... Original: https://github.com/postgres/postgres/blob/df293aed46e3133df3... Usage: https://github.com/malisper/pgrust/blob/3646a73515a5e4ac7d0b... The return type in the rewrite is both some sort of Error tagged union that supports the Try machinery in Rust; but, it also contains a boolean that apparently must be checked; or something. It seems labyrinthical and possibly broken and terrible. | ||||||||
| ▲ | khuey 2 hours ago | parent | next [-] | |||||||
I make no claim as to whether the change makes sense given that I didn't look at the callers of this function, but Result<bool> is an entirely reasonable pattern in Rust. If you want the callers to be able to distinguish between "has the subclass", "doesn't have the subclass", and "something went wrong" this is idiomatic Rust. | ||||||||
| ||||||||
| ▲ | pdevr 3 hours ago | parent | prev [-] | |||||||
It is a feature in Rust, not a bug :-) (I know you didn't say it is a bug.) The error-tagged union is PgResult<bool> - which means it contains bool as the result if things go well. (The other part in the union is of course the error.) In the original function also, it is returning a boolean: "bool has_subclass". So anyway you have to check for the boolean as part of the logic. That is what it is doing. | ||||||||
| ||||||||