Skip to content

morganlinton/BeautifulRust / skills/rust-port

rust-port

Verified

Port code from C, C++, Python, Go, JavaScript, or TypeScript into idiomatic Rust that keeps the original behavior: ownership instead of manual memory, Result instead of error codes and exceptions, enums instead of flag ints and magic strings, and tests that prove the port matches. Use this whenever the user asks to port, translate, convert, migrate, or rewrite code in Rust ("rewrite this in Rust", "what would this look like in Rust", "move this module to Rust"), even if they don't say "port". Pairs with the rust-best-practices skill, which covers the target code's style.

FileKindSize
SKILL.mdskill md8.1 KB
evals/port-c-config-parser/case.yamlconfig663 B
evals/port-c-config-parser/files/config.cother5.1 KB
evals/port-c-config-parser/files/config.hother1.3 KB
evals/port-c-config-parser/files/test_config.cother2.9 KB
evals/port-c-config-parser/graders/01-builds-and-tests-pass.mdmarkdown114 B
evals/port-c-config-parser/graders/02-clippy-clean.mdmarkdown89 B
evals/port-c-config-parser/graders/03-no-unsafe.mdmarkdown96 B
evals/port-c-config-parser/graders/04-every-test-ported.mdmarkdown289 B
evals/port-c-config-parser/graders/05-errors-as-result.mdmarkdown209 B
evals/port-c-config-parser/graders/06-error-implements-error.mdmarkdown108 B
evals/port-c-config-parser/graders/07-option-for-absent.mdmarkdown185 B
evals/port-c-config-parser/graders/08-typed-flags.mdmarkdown144 B
evals/port-c-config-parser/graders/09-behavior-preserved.mdmarkdown320 B
evals/port-c-config-parser/graders/10-porting-notes.mdmarkdown183 B
evals/port-c-config-parser/graders/11-proportionate.mdmarkdown467 B
evals/port-c-config-parser/place-files.shexecutablescript62 B
evals/port-c-config-parser/prompt.mdmarkdown459 B
evals/port-python-task-graph/case.yamlconfig628 B
evals/port-python-task-graph/files/taskgraph.pyscript4.1 KB
evals/port-python-task-graph/files/test_taskgraph.pyscript2.7 KB
evals/port-python-task-graph/graders/01-builds-and-tests-pass.mdmarkdown114 B
evals/port-python-task-graph/graders/02-clippy-clean.mdmarkdown89 B
evals/port-python-task-graph/graders/03-every-test-ported.mdmarkdown206 B
evals/port-python-task-graph/graders/04-exceptions-as-error-enum.mdmarkdown252 B
evals/port-python-task-graph/graders/05-kind-is-enum.mdmarkdown134 B
evals/port-python-task-graph/graders/06-priority-is-option.mdmarkdown105 B
evals/port-python-task-graph/graders/07-definition-order-preserved.mdmarkdown204 B
evals/port-python-task-graph/graders/08-order-and-cycle-match.mdmarkdown187 B
evals/port-python-task-graph/graders/09-summary-every-kind-in-order.mdmarkdown146 B
evals/port-python-task-graph/graders/10-porting-notes.mdmarkdown198 B
evals/port-python-task-graph/graders/11-proportionate.mdmarkdown473 B
evals/port-python-task-graph/place-files.shexecutablescript62 B
evals/port-python-task-graph/prompt.mdmarkdown435 B

evals/port-c-config-parser/files/config.h

View on GitHub
#ifndef CONFIG_H
#define CONFIG_H

/* Parse flags, OR them together. */
#define CONFIG_TRIM_VALUES      0x1  /* strip whitespace around values */
#define CONFIG_ALLOW_DUPLICATES 0x2  /* later keys overwrite earlier ones instead of failing */
#define CONFIG_CASE_INSENSITIVE 0x4  /* keys are compared case-insensitively */

/* Error codes returned through err_code. */
#define CONFIG_OK              0
#define CONFIG_ERR_SYNTAX     -1
#define CONFIG_ERR_DUPLICATE  -2
#define CONFIG_ERR_NOMEM      -3

/* config_get_int return values. */
#define CONFIG_INT_OK          0
#define CONFIG_INT_MISSING    -1
#define CONFIG_INT_NOT_NUMBER -2

typedef struct config config_t;

/* Parses INI-style text. Returns NULL on failure and sets *err_code and *err_line
 * (1-based) if they are non-NULL. Sections become key prefixes: "[db]\nport=5"
 * defines "db.port". Lines starting with '#' or ';' are comments. */
config_t *config_parse(const char *text, int flags, int *err_code, int *err_line);

/* Returns the value for key, or NULL if absent. The pointer stays valid until
 * config_free. */
const char *config_get(const config_t *cfg, const char *key);

/* Parses the value for key as a base-10 long into *out. */
int config_get_int(const config_t *cfg, const char *key, long *out);

/* Number of keys. */
int config_count(const config_t *cfg);

void config_free(config_t *cfg);

#endif
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall