我正在尝试学习JQuery,但做得不好.目前,我正在尝试学习如何使用.appendAjax功能,允许人们在不重新加载的情况下查看新的动态内容.但是,当我尝试以下操作时,什么也没发生.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>JQuery Test</title>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
</head>
<body>
<div id="content"/>
<script type="text/javascript">
function callback() {
$("#content").append($("qwerty"));
};
$(document).ready(function() {
//window.setTimeout(callback, 100);
callback();
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
据我所知,这应该使"qwerty"看起来好像我已经完成了<div id="content">qwerty</div>,但我得到一个空白页面.如果我用更换.append呼叫alert("qwerty"),则会正确显示.我究竟做错了什么?
我有一个实现特征的宏impl_Trait!().现在,它适用于没有通用参数的类型,但我不确定如何将类型参数添加到impl关键字.
macro_rules! impl_FooTrait {
($name:ty) => {
impl $crate::FooTrait for $name { ... }
};
}
struct Bar(i32);
impl_FooTrait!(Bar);
// All OK
struct Baz<'a>(&'a i32);
impl_FooTrait!(Baz<'a>);
// use of undeclared lifetime name `'a`
Run Code Online (Sandbox Code Playgroud) 我有一个类型定义为
Inductive bits : nat -> Set :=
| bitsNil : bits 0
| bitsCons : forall {l}, bool -> bits l -> bits (S l).
Run Code Online (Sandbox Code Playgroud)
我试图证明:
Lemma emptyIsAlwaysNil : forall {a: bits 0}, a = bitsNil.
Run Code Online (Sandbox Code Playgroud)
之后intros,我已经试过constructor 1,case a,intuition,无济于事。case a似乎是最接近的,但它得到一个错误:
Abstracting over the terms "0" and "a" leads to a term
fun (n : nat) (a0 : bits n) => a0 = bitsNil
which is ill-typed.
Reason is: Illegal …Run Code Online (Sandbox Code Playgroud) 我正在尝试在两种类型之间创建一个类型级别的映射,实现为关联列表,以便有效的映射实现特征:
trait Key {
const KEY: usize;
}
trait TypeLevelMap<K: Key, V> {
fn convert(K) -> V;
}
Run Code Online (Sandbox Code Playgroud)
零案例很简单:
struct TypeLevelMapNil<T>(PhantomData<T>);
impl<K: Key, V> TypeLevelMap<K, V> for TypeLevelMapNil<V> {
fn convert(k: K) -> V {
panic!("Unhandled case: {}", K::KEY);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我无法弄清楚这种情况:
struct TypeLevelMapCons<K, V, Tl, TlK, TlV>(PhantomData<(K, V, Tl, TlK, TlV)>);
impl<K, V, Tl, TlK, TlV> TypeLevelMap<K,V> for TypeLevelMapCons<K, V, Tl, TlK, TlV>
where
K: Key,
Tl: TypeLevelMap<TlK, TlV>,
TlK: Key,
{
fn convert(_k: K) -> V {
unimplemented!() …Run Code Online (Sandbox Code Playgroud) 我想编写一个可以分解操作其组件的路径的宏.例如:
macro_rules! example {
($path:path) => {
vec![
stringify!(get_path_init!($path)),
stringify!(get_path_last!($path)),
]
};
}
fn main() {
let path_parts = example!(std::vec::Vec);
assert_eq!(path_parts, vec!["std::vec", "Vec"]);
}
Run Code Online (Sandbox Code Playgroud)
在标准库或任何相当流行的板条箱中是否存在这样的东西,是否可以用宏实现?或者它需要编译器插件?
我正试图"半空" (ExceptT Error IO Foo)到一个(ExceptT Error (StateT Bar IO) Baz).
我试过了lift,fmap lift而且fmap return,没有工作; 这里有标准的习语吗?
> import Control.Monad.Except
> import Control.Monad.State
> data Error
> data Foo
> data Bar
> data Baz
> x = undefined :: ExceptT Error IO Foo
> y = undefined :: (ExceptT Error (StateT Bar IO) Baz) -> a
> f = ??? -- This is what I'm trying to find.
> :t y (f x) …Run Code Online (Sandbox Code Playgroud) 我正在尝试将列表转换\'(110 111 101 204 136 108)为字符串,如"noe\xcc\x88l".
我尝试使用(mapcar (lambda (c) (decode-char \'unicode c)) \'(110 111 101 204 136 108)),但结果是(110 111 101 204 136 108),与输入相同。(另外,我认识到无法从 UTF-8 的单个字节解码 Unicode 字符,因此这绝对是错误的函数。)
class A {
public:
A();
int get();
void set();
};
protected int A::var;
Run Code Online (Sandbox Code Playgroud)
好像它会起作用.但是,它"期望受保护之前的不合格身份".这样做的正确方法是什么?