Skip to content

fix(csharp-book): add Span<T> and Inline Arrays to Arrays and Slices#105

Open
rodrirejala wants to merge 2 commits into
microsoft:mainfrom
rodrirejala:fix/csharp-span-inline-arrays
Open

fix(csharp-book): add Span<T> and Inline Arrays to Arrays and Slices#105
rodrirejala wants to merge 2 commits into
microsoft:mainfrom
rodrirejala:fix/csharp-span-inline-arrays

Conversation

@rodrirejala
Copy link
Copy Markdown
Contributor

Fix #70
Add a new subsection "Modern C#: Span and Inline Arrays" to the
Arrays and Slices section of ch05, covering modern C# features missing
from the original C#→Rust comparison:

  • Span<T> / ReadOnlySpan<T> mapped to Rust &[T] / &str
  • C# 12 Inline Arrays ([InlineArray(N)]) mapped to Rust [T; N]
  • stackalloc + Span<T> mapped to local arrays
  • Comparison table with 5 key equivalences
  • Key insight callout explaining Rust's &[T] as a unified fat pointer

Also marks the mermaid preprocessor as optional = true in book.toml
so the book builds without mdbook-mermaid installed. ^_^

Use RefCell for interior mutability so alloc takes &self instead of &mut self,
resolving the borrow checker conflict between alloc and get.
Fixes microsoft#102
Add a new subsection 'Modern C#: Span<T> and Inline Arrays' to the
Arrays and Slices section of ch05, covering:
- Span<T> / ReadOnlySpan<T> mapped to Rust &[T] / &str
- C# 12 Inline Arrays mapped to Rust [T; N]
- stackalloc + Span<T> mapped to local arrays
Also mark the mermaid preprocessor as optional in book.toml
so the book builds without mdbook-mermaid installed.
Fixes microsoft#70
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.

Article for C# developer should also mention Span<T> and inline arrays

1 participant