Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #20

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Refs #20

wants to merge 11 commits into from

Conversation

5GameMaker
Copy link

It's fearless, it's concurrent, and it's repr C.

For people who want to do manual memory management, there are now new and free functions which return and accept Ref<T>. Those functions replicate how those work in C, allowing free moving and mutating.

Essentially Ref<T> disables borrow checker. This addresses the criticism of Rust being a difficult to use language due to borrow checker enforcing safety rules, which, as we can deduce from the amount of memory-management-related CVEs, is a hard thing for human beings to manage.

@5GameMaker
Copy link
Author

Correction: new is a C++ feature

src/references.rs Show resolved Hide resolved
src/references.rs Show resolved Hide resolved
src/references.rs Outdated Show resolved Hide resolved
T: Sized,
{
reff.free()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove the module-level fns now that they're methods

Copy link
Author

@5GameMaker 5GameMaker Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those functions exist as to be inclusive towards the C/C++ developer community. Those can be removed, but it will make Rust less accessible for that group.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ought to make them extern "C" in that case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ye makes sense

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, those have names which cannot be exported

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm
maybe #[export(cve_rs_malloc)]/free?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No such attribute

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo mommy lmfao

src/references.rs Outdated Show resolved Hide resolved
@Bright-Shard
Copy link
Collaborator

Bright-Shard commented Feb 22, 2024

Since this library is extremely popular, we need to keep safety and speed as top priorities, but also code quality :)

(this is definitely real logic and not just me giving you a hard time)

Dropping `Sync` requirement for a `Ref` to be `Send`+`Sync`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants