Skip to content

Strange mapping of struct functions #23

@mipastgt

Description

@mipastgt

I tried to use a struct from Java/Kotlin code and the mapping of methods seems a bit strange to me. The following test compiles and runs but I would have rather expected static functions here to avoid this dummy instance. It would also be tempting to map structs to real classes with constructors and instance methods but I am not sure whether that would actually be fully compatible with Rust. So, static methods seem to be the safer bet to me at the moment.

    @Test
    fun test_impl() {
        val dummy = NamedCounter()
        val counter = dummy.new("Michael", 99)
        val limit = dummy.get_limit(counter)
        assert(limit == 99L)

// Shouldn't this rather be mapped to static functions like this?
//        val counter = NamedCounter.new("Michael", 99)
//        val limit = NamedCounter.get_limit(counter)
//        assert(limit == 99L)
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions