Forwarded from Alex Ilizarov
Я: Сэкономлю ка я тут байтик на clone()
Компилятор:
'a 'vot 'xuy
^ does not live long enough
Компилятор:
'a 'vot 'xuy
^ does not live long enough
Forwarded from hirrolot
GitHub
GitHub - lloydmeta/frunk: Funktional generic type-level programming in Rust: HList, Coproduct, Generic, LabelledGeneric, Validated…
Funktional generic type-level programming in Rust: HList, Coproduct, Generic, LabelledGeneric, Validated, Monoid and friends. - lloydmeta/frunk
Forwarded from p0lunin
https://m.habr.com/ru/post/495366/ ищем себя
Хабр
16 типов программистов, или Разработчики – это не одинаковые роботы
Часто можно услышать такие слова, как “впишется / не впишется в коллектив” в адрес того или иного разработчика. У кого-то это вызывает возмущение, у кого-то руки опускаются после очередного...
Forwarded from hirrolot
Есть книга по функциональному программированию на Rust (если надо - в личинку перекину). Вот есть репозиторий с шаблонами:
https://github.com/rust-unofficial/patterns
https://github.com/rust-unofficial/patterns
GitHub
GitHub - rust-unofficial/patterns: A catalogue of Rust design patterns, anti-patterns and idioms
A catalogue of Rust design patterns, anti-patterns and idioms - rust-unofficial/patterns
Forwarded from The Wacky Yellow Dog
Очень много нетривиальной возни с пинами и ряд связанных с этим проблем:
https://internals.rust-lang.org/t/unsoundness-in-pin/11311
https://internals.rust-lang.org/t/unsoundness-in-pin/11311
Rust Internals
Unsoundness in `Pin`
Recently, @withoutboats challenged me to demonstrate a hypothetical version of Pin with different guarantees, and show how it would be sound. However, while working on that, I stumbled upon unsoundness in the actual Pin. I haven't seen this reported before…
Forwarded from Deleted Account
Pin unsound в теории, а async await unsound вот почему https://github.com/rust-lang/rust/issues/63818
GitHub
Resolve unsound interaction between noalias and self-referential data (incl. generators, async fn) · Issue #63818 · rust-lang/rust
Self-referential generators violate LLVM's expectations for noalias due to the overlapping bounds of the interior references and the &mut self argument to the Generator::resume function. Or...
Forwarded from Stanislav Popov
моё творчество от безделья
def get_parents_list(clause) -> List[models.Category]:
beginning_getter = models.Category.query.filter(clause).cte(name="parent_for", recursive=True)
with_recursive = beginning_getter.union_all(
models.Category.query.filter(models.Category.id == beginning_getter.c.parent_id)
)
return DBSession.query(models.Category).select_entity_from(with_recursive).all()
Forwarded from Deleted Account
https://blog.zaletskyy.com/hierarchical-storage-of-data-in-databases вариантов много, надо выбирать под задачу, точнее вообще не делать так в реляционной базе
Forwarded from Stanislav Popov
насколько я помню я просто заюзал это https://gist.github.com/fritzy/10427e8032d77ded8e13
Gist
Fight the German Tank Problem in Postgresql with short, unique, url-safe ids.
Fight the German Tank Problem in Postgresql with short, unique, url-safe ids. - 1unique_short_id.sql
Forwarded from p0lunin
https://github.com/tokio-rs/tokio/blob/master/examples/hello_world.rs
вот хеловорд с сокетами
тебе нужно просто прослушивать сокет, и кидать данные в serde_json после прочтения
вот хеловорд с сокетами
тебе нужно просто прослушивать сокет, и кидать данные в serde_json после прочтения
GitHub
tokio/examples/hello_world.rs at master · tokio-rs/tokio
A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ... - tokio-rs/tokio
Forwarded from Αλεχ Zhukovsky
https://boats.gitlab.io/blog/post/why-ok-wrapping/ снова изобретаем монады
withoutblogs
A brief apology of Ok-Wrapping
I’ve long been a proponent of having some sort of syntax in Rust for writing functions which return results which “ok-wrap” the happy path. This is has also always been a feature …
Forwarded from dørk pit
как-то раньше не задумывался, но ведь можно юзать голый
и заодно дженерики с лайфтаймами попрактиковал.
https://gist.github.com/ratijas/c0122a7ec276966513f8f6e92bd080d0
Box<[T]>
для многомерных массивов.и заодно дженерики с лайфтаймами попрактиковал.
https://gist.github.com/ratijas/c0122a7ec276966513f8f6e92bd080d0
Gist
Using Box<[T]> in Rust for multi-dimensional arrays
Using Box<[T]> in Rust for multi-dimensional arrays - playground.rs
Forwarded from Deleted Account
Дело в том, что C++ - язык свободных и ответственных людей, а не фанатиков, которые скоро будут воздвигать алтари компиляторам и приносить на них в жертву своих детей ради чуть большей безопасности. Поэтому выбор инструментария в нем не ограничен. Ну и как писал Франклин в своём последнем блоге про Rust: "Те, кто готов променять свою свободу на маленькую толику безопасности, не заслуживают ни свободы, ни безопасности!"
Forwarded from Ivan Boldyrev
Вот, кстати, задания с одного лондонского митапа для начинающих (точнее, это было dojo)
https://github.com/LukeMathWalker/build-your-own-jira-with-rust
https://github.com/LukeMathWalker/build-your-own-jira-with-rust
GitHub
GitHub - LukeMathWalker/build-your-own-jira-with-rust: A test-driven workshop to learn Rust building your own JIRA clone!
A test-driven workshop to learn Rust building your own JIRA clone! - LukeMathWalker/build-your-own-jira-with-rust
Forwarded from Deleted Account
Потому что функции это дескрипторы, биндящиеся при получении как поле объекта. Это делает возможным огромное количество магии.
Forwarded from Deleted Account
Например, позднюю привязку методов:
>>> def print_self(self):
... print(self)
...
>>>
>>> class C: pass
>>> a = C()
>>> C.print_self = print_self
>>> a.print_self()
<__main__.C object at 0x7f18dd744d60>
Forwarded from Deleted Account
Или даже хуже:
>>> def print_self(self):
... print(self)
...
>>>
>>> a = object()
>>> method = print_self.__get__(a)
>>> method()
<object object at 0x7f75edaf9e40>