Skip to content

A partial implementation of Rust's std::fmt in roblox-ts

License

Notifications You must be signed in to change notification settings

memolemo-studios/rbxts-rustfmt

Repository files navigation

@memolemo-studios/rustfmt

A partial implementation of Rust's std::fmt for roblox-ts (in Roblox).

Example

roblox-ts:

import { fmt, implDebug } from "@memolemo-studios/rustfmt";

// Should print:
// Hello Instance(Workspace)
print(fmt("{} {:?}", "Hello", game.GetService("Workspace")));

const person = {
    name: "Adam",
    age: 10,
};
implDebug(person, (value, fmt) =>
    fmt.debugStruct("Person")
        .field("name", value.name)
        .field("age", value.age)
        .finish()
);

// Should print:
// Person {
//     name: "Adam",
//     age: 10,
// }
print(fmt("{:#?}", person));

Luau:

local rustfmt = require(path.to.rustfmt)

-- Should print:
-- Hello Instance(Workspace)
print(rustfmt.fmt("{} {:?}", "Hello", game:GetService("Workspace")))

local person = {
    name = "Adam",
    age = 10,
}
rustfmt.implDebug(person, function(value, fmt)
    fmt:debugStruct("Person")
        :field("name", value.name)
        :field("age", value.age)
        :finish()
end);

-- Should print:
-- Person {
--     name: "Adam",
--     age: 10,
-- }
print(fmt("{:#?}", person))

About

A partial implementation of Rust's std::fmt in roblox-ts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages