Skip to content

Add no_panic feature#28

Open
malbarbo wants to merge 1 commit into
Alexhuszagh:mainfrom
malbarbo:no_panic
Open

Add no_panic feature#28
malbarbo wants to merge 1 commit into
Alexhuszagh:mainfrom
malbarbo:no_panic

Conversation

@malbarbo

Copy link
Copy Markdown

No description provided.

@malbarbo

Copy link
Copy Markdown
Author

I'm using this crate and producing some wasm file, when this feature is enabled, the size of the wasm file is reduced.

@Alexhuszagh Alexhuszagh left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Sorry for the massive delay: for some reason I didn't get any notifications from Github for a period. My email is in my Github bio for whatever reason in case I stop getting Github emails: feel free to reach out to me directly there as well.

The general approach looks good, I do have a few changes I'd like to see, specifically to ensure safety invariants are guaranteed (or, in no-panic mode, if they are not).

Security issues have been an issue: when I took over this fork, there was a lot of non-local safety invariants and also some undefined behavior that was fixed. So although everything is sound here, I'd much rather these be very clearly documented, both for source maintainers and for end-users, the panic behaviors.

Comment thread src/decimal.rs
pub fn parse_decimal(mut s: &[u8]) -> Decimal {
// can't fail since it follows a call to parse_number
assert!(!s.is_empty(), "the buffer cannot be empty since it follows a call to parse_number");
debug_assert!(

@Alexhuszagh Alexhuszagh Jul 25, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I feel this should be an assert in normal mode (it will be optimized out) and only debug_assert in no-panic mode. I like my strong safety invariants by default. Maybe create a shim for the macro? nopanic_assert?

Comment thread src/lib.rs
T::parse_float_partial(s)
}

pub trait GetAt<Index, R: ?Sized> {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't think this should be exposed as part of the public API and should be clearly documented to use unsafe code in no-panic mode.

Comment thread README.md

## Features

`no-panic`: when this feature is enabled, the crate guarantees that it will not trigger a runtime panic.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should clearly document that unsafe code is used to this effect.

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