边界条件之场
66 subscribers
680 photos
4 videos
10 files
1.03K links
Do you hear the sirens sing?

main: @cvf_cha
group: @cvf_gro
forwards: @cvf_for
Download Telegram
小米随线刷包分发的刷机脚本竟然直接是错的……
(对调了 opcustopconfig

虽然我对中国厂商的软件分发质量没有任何期待,但这也有点太离谱了吧

#trash #xiaomi
边界条件之场
小米随线刷包分发的刷机脚本竟然直接是错的…… (对调了 opcust 跟 opconfig ) 虽然我对中国厂商的软件分发质量没有任何期待,但这也有点太离谱了吧 #trash #xiaomi
小米随包分发两个版本的刷机脚本:
- flash_all
- flash_all_except_storage
(忽略 flash_all_lock ,脑子进屎了才会给用 hyperos 的小米设备重新上锁(

两个脚本均提供 .bat.sh 格式, opcustopconfig 对调的错误仅存在于 flash_all_except_storage.bat 。某种程度上比全错更加离谱……

2024-01-17 构建的包是错的,2024-03-08 构建的包还是错的。我估计能一直错到小米 13 停止支持,不知道其它设备的脚本是不是也是错的。
另:2024-03-08 构建的包直到四月中旬才发出来……
#wtf #trash #xiaomi
🤡1
https://www.reddit.com/r/rust/comments/1cdqdsi/comment/l1e722d/

For instance, the orphan rule is *absolutely* a problem. It affects ecosystem scaling in multiple ways. It means that if you have a library A providing a trait and a library B providing a type, either A has to add optional support for B or B has to add optional support for A, or someone has to hack around that with a newtype wrapper. Usually, whichever library is less popular ends up adding optional support for the more popular library. This is, for instance, one reason why it's *really really hard* to write a replacement for serde: you'd have to get every crate currently providing optional serde support to provide optional support for your library as well.

In other ecosystems, you'd either add quick-and-dirty support in your application, or you'd write (and perhaps publish) an A-B crate that implements support for using A and B together. This should be possible in Rust.

There are a few potential language solutions to that. The simplest, which would likely be fairly easy and would help many applications, would be "there can only be one implementation of a trait for a type", giving a compiler error if there's more than one.
Forwarded from iBug Thought �
Telegram Desktop 更新了 5.0,中文字体又原地寄了
🤡1
边界条件之场
用上了阳间版本的依赖后 host stack 很快就跑通了 😌 测试 hid 键盘报文 Ctrl-Shift-C, Ctrl-Shift-V : ( 0000 0000 ) [ 00 00 00 00 00 00 ] ( 0000 0001 ) [ 00 00 00 00 00 00 ] ( 0000 0011 ) [ 00 00 00 00 00 00 ] ( 0000 0011 ) [ 06 00 00 00 00 00 ] ( 0000 0011 ) [ 00 00 00 00 00 00 ] (…
no_std rust (准确说是 no alloc) 难度比普通 rust 高好多 🫠
没有 VecVecDeque 还行,手动搓个 stack ring buffer 凑合。
没有 Box 就很麻烦了,难以实现 list of owned trait objects 。用 &dyn Trait 的话 ownership 跟 lifetime 让人头大,用 enum 的话灵活性太差。
真的很想依赖个 allocator crate 算了 🫠
边界条件之场
this is doable in safe stable rust?? 👀 https://guiand.xyz/blog-posts/unboxed-trait-objects.html
看了看 dynstack 的源码,虽然 no_std 但是 extern crate alloc; 🥴
我还是用 enum 吧,简单直接,灵活性实际上也没问题(就是麻烦点
这周的大部分时间没网, rustup doc --pathpython -m http.server ... 真是太好用了 🥰
边界条件之场
看了看 dynstack 的源码,虽然 no_std 但是 extern crate alloc; 🥴 我还是用 enum 吧,简单直接,灵活性实际上也没问题(就是麻烦点
不行,enum 问题很大 🥴 #rust

假设我有 trait A ,为了解决 no alloc no owned trait object 的问题,再尝试定义一个 enum AHelper 包裹所有 impl A 的类型。

现在我要一个 struct B<T: A> { field: T } , impl<T: A> A for B<T> ,尝试把 B 囊括进 AHelper:

enum AHelper<T: A> {
B(B<T>)
}


这个 enum 定义是合法的,但是使用时(在我的知识范围内)完全无法达成规避 trait object 的目的。因为我需要 T 类似 trait object ,没有 trait object 那就尝试用 AHelper 。然而用 AHelper 会导致 recursive type AHelper<AHelper<...>>>
边界条件之场
不行,enum 问题很大 🥴 #rust 假设我有 trait A ,为了解决 no alloc no owned trait object 的问题,再尝试定义一个 enum AHelper 包裹所有 impl A 的类型。 现在我要一个 struct B<T: A> { field: T } , impl<T: A> A for B<T> ,尝试把 B 囊括进 AHelper: enum AHelper<T: A> { B(B<T>) } 这个 enum 定义是合法的,但是使用时(在我的知识范围内)完全无法达成规避…
&dyn Trait 在我的使用场景下也没法用,因为我要在运行时 .clone() ,不能 own 的话 clone 完没地方存。或者需要给每个 impl Trait 的类型都准备一个 buffer 来存,可维护性和可拓展性感觉会很糟糕……

想一想可能真的需要「依赖个 allocator crate 算了」🫠
但我是从 c binary link rust static lib,不了解 rust 这边额外跑个 allocator 会不会有什么问题
边界条件之场
hmmmmm, 实际上也用不了 trait object 🤔 有点棘手
为了使 trait object safe ,我可以把 proceed 函数的 function generic const 改成 trait generic ,再扩散成某个 struct generic 。但那样会由于 struct init 的时候无法 infer 这些 generic const 而需要显式写出,导致之后调用 proceed 时无法随意传入 const 参数不同的变量。
不是个大问题,但不爽(
边界条件之场
为了使 trait object safe ,我可以把 proceed 函数的 function generic const 改成 trait generic ,再扩散成某个 struct generic 。但那样会由于 struct init 的时候无法 infer 这些 generic const 而需要显式写出,导致之后调用 proceed 时无法随意传入 const 参数不同的变量。 不是个大问题,但不爽(
不打算让 trait object safe ,那就需要一个类似 trait object 但又不是 trait object 的东西。之前提到的 enum AHelper 存在 recursive type 问题,需要引入某种 indirection 来解决。我需要 owned indirection, Box 虽然没能被用于 trait object ,但这回应该没问题:

enum AHelper {
B(B<Box<AHelper>>)
}