Skip to content

Fix whitespace handling in main detection - #16

Open
YetForge wants to merge 1 commit into
micanzhang:masterfrom
YetForge:fix/main-whitespace-detection
Open

YetForge wants to merge 1 commit into
micanzhang:masterfrom
YetForge:fix/main-whitespace-detection

Conversation

@YetForge

Copy link
Copy Markdown

Fixes #15

ob-rust currently looks for the exact string fn main() before deciding whether to wrap a Rust source block in a generated main function.

Valid Rust formatting with whitespace in the declaration can therefore go undetected and cause the block to be wrapped in an extra main.

This change makes main detection tolerate whitespace between fn and main, and before the opening parenthesis.

The existing behavior for blocks without a main function is unchanged.

Regression coverage is added to the existing ob-rust test suite for both whitespace cases while preserving the existing wrapper behavior.

Tests: make test — 5/5 passed.

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.

Whitespace before ( breaks main detection

1 participant