Похожие чаты

Anyone familiar with unsafe Rust? I'm writing a simple container type

as an internal storage for another type. It is something like Vec, but stores 3 different internal arrays (within one buffer), and it has limited list of operations that it supports.

I wonder if I made it correctly, and it can be safely used.

https://github.com/gameraccoon/sparse_set_container/blob/manual-memory-management/src/storage.rs

It looks sound to me, but I may have missed something obvious

3 ответов

7 просмотров

the naming is quite confusing(I generally implement is with index and data arrays rather than dense and sparse arrays, having dense array in sparse storage just feels confusing) for me But otherwise at a glance it seems fine you could write tests or borrow some tests from comparable libraries and try those.

Only Why start the start_ptr's out as dangling? Why not null_mut like the buffer ptr?

Pavel- Автор вопроса
Thomas
Only Why start the start_ptr's out as dangling? Wh...

Slices require a properly aligned pointer even when the size is empty, so to avoid explicit zero checks I had to use "dangling" which would provide such an aligned pointer. For buffer there's no requirements, so I just left it null

Похожие вопросы

Обсуждают сегодня

Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
I love the passion, really do. I do think this is being blown way out of proportion. We are not deleting our Telegram or not allowing you to talk about anything you want, a...
Mike Herron
3
Did you guys see the latest tweet from TonGifts? 🚀
Mike
44
Hey guys, did you see the latest announcement about $FUN? 🔥
Brian
21
Question: when will have qnt holders a tool to stake tokens in lcx? Answer, Verdian: yes soon.
David Ch
14
Did kadena deliver anything on time?
Femboi Uwu
23
А как лучше конвертировать физический адрес в виртуальный при маппинге? В случае ядра у меня, например, direct mapping, первые 768МБ я как есть мапплю в higher half, а остальн...
Evg Resh
26
Всем привет, подскажите/посоветуйте пожалуйста. Фаердак компоненты, имею одно место где бизнес хочет видеть при открытии формы список всех клиентов, это порядка 30к. Мои дово...
Sasha Sch
14
Ребят, если кто в курсе - скажите, а в загранке такое же засилье маркетплейсов? или там простые сермяжные интернет-магазины живут попроще?
Андрей [aharito] Харитонов
14
Коллеги, доброе утро. Запустил на удаленном хосте приложение (ручками зашел туда по ssh и запустил, не командой удаленно). Создал потом ssh-туннель, и с моей машины приложение...
Δημήτηρ
9
Карта сайта