New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expr/builtin_fncall: implement Inet6Aton #3480
Conversation
Signed-off-by: sweetIan <ian.d2d@qq.com>
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
let input = try_opt!(self.children[0].eval_string_and_decode(ctx, row)); | ||
let ipv6_addr = Ipv6Addr::from_str(&input).map(|t| Some(Cow::Owned(t.octets().to_vec()))); | ||
let ipv4_addr = Ipv4Addr::from_str(&input).map(|t| Some(Cow::Owned(t.octets().to_vec()))); | ||
ipv6_addr.or(ipv4_addr).or(Ok(None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use or_else
instead of or
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hicqu Do you mean that we need to lazy evaluate ipv4_addr? How about write it as below?
let input = try_opt!(self.children[0].eval_string_and_decode(ctx, row));
let ipv6_addr = Ipv6Addr::from_str(&input).map(|t| Some(Cow::Owned(t.octets().to_vec())));
let ipv4_addr_eval =
|_t| Ipv4Addr::from_str(&input).map(|t| Some(Cow::Owned(t.octets().to_vec())));
ipv6_addr.or_else(ipv4_addr_eval).or(Ok(None))
rest LGTM. PTAL @breeswish . |
Signed-off-by: sweetIan <ian.d2d@qq.com>
LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Signed-off-by: sweetIan <ian.d2d@qq.com>
Signed-off-by: sweetIan ian.d2d@qq.com
What have you changed? (mandatory)
expr/builtin_fncall: implement Inet6Aton
What are the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
unit test
Does this PR affect documentation (docs/docs-cn) update? (mandatory)
no
Does this PR affect tidb-ansible update? (mandatory)
no
Refer to a related PR or issue link (optional)
#3275