1
chainal7777 2024-07-09 21:24:03 +08:00
1 ,用点 use as
2 ,用点 type A=a 3 ,只写关键注释 |
![]() |
2
RedBeanIce OP @chainal7777 请问第一点是什么意思呀,,,,‘’第二点我大概理解,就是将泛型定义变成单独的一行代码。
|
3
cppc 2024-07-09 23:56:28 +08:00 via iPhone
为了安全是这样啦,我还见过编译时 SQL 检查呢,SQL 写错代码都不能编译
|
![]() |
4
PTLin 2024-07-10 13:41:06 +08:00
不是 rust 复杂,这个是库复杂,用了太多泛型了
|
![]() |
5
whoami9894 2024-07-30 11:43:45 +08:00
有没有可能,不用写那么多类型标注
另外,函数当然不可能接收 [u8; const N] 参数,难道你能在编译期知道数据长度? ``` let key = Aes256Gcm::generate_key(OsRng); let cipher = Aes256Gcm::new(&key); let nonce = Aes256Gcm::generate_nonce(OsRng); let plaintext = b"plaintext message"; let ciphertext = cipher.encrypt(&nonce, plaintext.as_slice()).unwrap(); let plaintext = cipher.decrypt(&nonce, ciphertext.as_slice()).unwrap(); assert_eq!(&plaintext, b"plaintext message"); ``` |