Skip to content

Add interactive string interop example with ownership and user flow#40

Draft
shashu8660 wants to merge 23 commits intorustfoundation:mainfrom
shashu8660:add-example2
Draft

Add interactive string interop example with ownership and user flow#40
shashu8660 wants to merge 23 commits intorustfoundation:mainfrom
shashu8660:add-example2

Conversation

@shashu8660
Copy link
Copy Markdown
Contributor

This PR adds an interactive string interoperability example between Rust and C++.

The example demonstrates:

  • Passing strings from C++ to Rust using const char*
  • Returning strings from Rust to C++ using CString
  • Ownership transfer across the FFI boundary (Move, Forget, Own)
  • Safe memory management and explicit deallocation
  • Interactive user input flow

The example includes:

  • Rust library exposing FFI functions
  • C++ program handling user input and interaction
  • run.sh script for building and running the example

This aligns with the string interop problem https://github.com/rustfoundation/interop-initiative/blob/main/problem-space/0002-string-interop.md & demonstrates safe handling of string ownership and memory across language boundaries

@teor2345
Copy link
Copy Markdown
Collaborator

Hi, I've already looked at your PR #30, we're just going to focus on one PR per person for now. After that PR is finished, we can decide what to do with this one.

@teor2345 teor2345 marked this pull request as draft March 30, 2026 01:28
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