Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Jan 13, 2026

Summary

This PR implements Rust-specific tuple conversion support for Links Notation, enabling ergonomic link creation using native Rust tuple syntax. This feature brings Rust implementation closer to feature parity with C#, which already supports tuple conversion via implicit operators.

Changes

Core Implementation

  • Added From trait implementations for tuple to LiNo<String> conversion in rust/src/lib.rs
  • Support for 2-tuple through 4-tuple conversions
  • Support for multiple tuple type combinations:
    • String tuples: (&str, &str), (String, String), etc.
    • Mixed tuples: (&str, LiNo<String>), etc.
    • LiNo tuples: (LiNo<String>, LiNo<String>), etc.

Test Coverage

  • Added 16 comprehensive tests in rust/tests/tuple_tests.rs
  • Tests cover:
    • Basic tuple to link conversion
    • Owned vs borrowed strings
    • Mixed tuple types
    • Anonymous links from LiNo tuples
    • Nested link structures
    • Complex examples matching C# implementation
    • Edge cases and special characters

Documentation

  • Updated rust/README.md with comprehensive tuple conversion section
    • Basic usage examples
    • Mixed tuple type examples
    • Complex nested structure examples
    • Complete list of supported conversions
  • Updated main README.md to reflect Rust-specific feature

Usage Examples

Basic Tuple Conversion

use links_notation::LiNo;

// Convert a 2-tuple to a link
let link: LiNo<String> = ("papa", "mama").into();
println!("{}", link); // (papa: mama)

// Convert a 3-tuple to a link
let link: LiNo<String> = ("papa", "loves", "mama").into();
println!("{}", link); // (papa: loves mama)

Complex Nested Structures

use links_notation::{format_links, LiNo};

let loves_mama: LiNo<String> = ("lovesMama", "loves", "mama").into();
let papa: LiNo<String> = ("papa", loves_mama).into();
let son: LiNo<String> = ("son", "lovesMama").into();

let links = vec![papa, son];
let result = format_links(&links);
// Output:
// (papa: (lovesMama: loves mama))
// (son: lovesMama)

Testing

All tests pass successfully:

  • ✅ 16 new tuple conversion tests
  • ✅ All existing tests (110+ tests) continue to pass
  • ✅ Code formatting (cargo fmt)
  • ✅ Linting (cargo clippy)
  • ✅ No warnings or errors

Comparison with C#

This implementation mirrors C#'s tuple conversion feature but uses Rust's From trait instead of implicit operators:

C#:

LinkType link = ("papa", "mama");

Rust:

let link: LiNo<String> = ("papa", "mama").into();

Feature Parity

With this PR, Rust now has feature parity with C# for tuple conversion, making the library more ergonomic and intuitive for Rust developers.

Fixes #200


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #200
@konard konard self-assigned this Jan 13, 2026
Implement From trait conversions for Rust tuples (2-tuple through 4-tuple)
to LiNo<String>, enabling ergonomic syntax similar to C#'s tuple conversion.

Features:
- Support for string tuples: (&str, &str), (String, String), etc.
- Support for mixed tuples: (&str, LiNo<String>), etc.
- Support for LiNo tuples: (LiNo<String>, LiNo<String>), etc.
- Anonymous links from multiple LiNo values
- Comprehensive test coverage with 16 new tests

This brings Rust implementation closer to feature parity with C#,
allowing developers to create links using native Rust tuple syntax.

Fixes #200

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Tuple to Links Notation and Links Notation to Tuple Add Rust tuple conversion support for ergonomic link creation Jan 13, 2026
Create comprehensive example showing:
- Basic 2-tuple, 3-tuple, and 4-tuple conversions
- Mixed tuples with LiNo values
- Anonymous links from LiNo tuples
- Complex nested structures
- Ergonomic collection creation
- Owned String tuple conversion

Example can be run with: cargo run --example tuple_conversion

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@konard konard marked this pull request as ready for review January 13, 2026 12:21
@konard
Copy link
Member Author

konard commented Jan 13, 2026

⚠️ Solution Draft Finished with Errors

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $2.595061 USD
  • Calculated by Anthropic: $0.000000 USD
  • Difference: $-2.595061 (-100.00%)

Note: The session encountered errors during execution, but some work may have been completed. Please review the changes carefully.

📎 Log file uploaded as Gist (571KB)
🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

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.

Tuple to Links Notation and Links Notation to Tuple

2 participants