Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Vee Satayamas
Vee Satayamas

Posted on

     

[Programming Notes] Pseudo-REPL-driven programming in Rust with Evcxr and Emacs

I want to develop my Rust library more interactively with Lisp-style read-eval-print loop (REPL). So I wrote this post to show how I used Excvr - yet another REPL for Rust, andinf-excvr - yet another Excvr wrapper for Emacs, step-by-step.

  • I cloned the project thewordcut-engine project, and open README.md in Emacs.

Image description

  • I ran inf-evcxr, which it created a newinf-evcxr window.

Image description

  • I add the project as dependency by running inf-evcxr-add-dep-current-project.

  • I marked a region over use commands, and ran inf-evcxr-eval-region.

Image description

  • I marked a region over initialization code block, and ran inf-evcxr-eval-region.

  • I moved the cursor to let txt = "หมากินไก่"; and I ran inf-evcxr-eval-line.

  • I moved the cursor to wordcut.put_delimiters(txt, "|"). Then I ran inf-evcxr-eval-line. The REPL printed the result of word tokenizer (wordcut::put_delimiters).

Image description

  • I did the same on wordcut.build_path(txt, &txt.chars().collect::>()). The REPL printed a graph that used for word tokenization.

Image description

  • I could let the REPL show prettier result by evaluating dbg!(wordcut.build_path(txt, &txt.chars().collect::>()));.

Image description

  • I redefined txt to กากินกิน, and ran the word tokenizer again.

Image description

This allows me to experiment with and manually test functions by varying the input variables to different strings and checking the results in simple strings or even internal structures, without recompiling the program or reloading the data. This is helpful for manual testing and debugging.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I'm a Thai-Lao-English-speaking software engineer who has worked on data pipelines, web/app back-end, and multilingual text processing.
  • Location
    SE Asia
  • Work
    software engineer
  • Joined

More fromVee Satayamas

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp