问题描述
pub enum TypeExpr {
Ident((String,Span)),// other variants...
}
和类型lhs
的值&Box<TypeExpr>
。如何检查它是否是值为{float”的Ident
?
我尝试过
if let TypeExpr::Ident(("float",lhs_span)) = **lhs {}
,但这不起作用,因为TypeExpr
包含String
,而不是&str
。我尝试了我能想到的每种模式的变化,但似乎无济于事。
解决方法
如果您确实想使用$('#popup a.like-btn').click(function(e) {
e.preventDefault(); // because clicking it kept changing my page URL; unsure this actually worked
$(this).find('.b').append('d'); // "like" word to "liked"
var postID = $('#popup .contents').attr('id');
$('.main').find("#" + postID).find('.like-btn').trigger("click");
});
进行此操作,则可能必须这样做
if let
当然,也可以使用if let TypeExpr::Ident((lhs_name,lhs_span)) = lhs {
if lhs_name == "float" {
// Do the things
}
}
:
match