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

Add CString implementation #372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add CString implementation #372

wants to merge 1 commit into from

Conversation

Sytten
Copy link
Contributor

@Sytten Sytten commented Oct 8, 2024

This allows users to avoid a double allocation for strings when you don't need to mutate the string.

Copy link
Owner

@DelSkayn DelSkayn left a comment

Choose a reason for hiding this comment

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

Looks good overall! Just some minor comments.

/// Rust representation of a JavaScript C string.
#[derive(Debug)]
pub struct CString<'js> {
ptr: *const c_char,
Copy link
Owner

Choose a reason for hiding this comment

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

This should probably be a NonNull.
Feels more correct as this pointer should never be null and might allow for more optimizations within enums.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

ctx: Ctx<'js>,
}

#[allow(dead_code)]
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this attribute here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bad copy paste

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.

2 participants