Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/YujinGaya/josa
Idiomatic josa selector in rust
https://github.com/YujinGaya/josa
Last synced: about 1 month ago
JSON representation
Idiomatic josa selector in rust
- Host: GitHub
- URL: https://github.com/YujinGaya/josa
- Owner: yujingaya
- Created: 2019-10-25T15:47:44.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-26T11:20:56.000Z (about 5 years ago)
- Last Synced: 2024-05-14T11:44:31.454Z (7 months ago)
- Language: Rust
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-hangul - josa - Idiomatic josa selector (Programming Languages / Rust)
README
# Josa
> Idiomatic [josa](https://en.wikipedia.org/wiki/Korean_postpositions) selector.![crates.io version][version] ![crates.io license][license] ![crates.io download][download]
Josa is a [Rust] library to select appropriate josas for korean language.
## Overview
### `push_josa` method
Josa is an [extension trait] implemented for [`String`] type.
Its API works just like [`push_str`] method on [`String`].```rust
use josa::JosaExt;
use josa::{EunNeun, IGa};let mut user = "유진".to_owned();
let mut mackerel = "고등어".to_owned();user.push_josa(EunNeun);
mackerel.push_josa(IGa);let sentence = format!("{} {} 먹고싶다", user, mackerel);
assert_eq!(sentence, "유진은 고등어가 먹고싶다");
```> :warning: Like [`push_str`] does, `push_josa` expects [`String`], not [`str`], as its argument.
### `+`, `+=` operator
You can use `+`, `+=` operator to append josa.```rust
use josa::{EunNeun, IGa};let user = "유진".to_owned();
let mackerel = "고등어".to_owned();let sentence = format!("{} {} 먹고싶다", user + EunNeun, mackerel + IGa);
assert_eq!(sentence, "유진은 고등어가 먹고싶다");
```### `select` method
In case you want to append a josa to formatted text such as `고양이`,
you can use `select` method.```rust
use josa::select;
use josa::IGa;let cat = "고양이";
let josa = select(cat, IGa).unwrap();let cat = format!(r#"{}{}"#, cat, josa);
assert_eq!(cat, r#"고양이가"#);
```## Usage
Add `josa` as a dependency in your `Cargo.toml`.```toml
[dependencies]
josa = "0.1.2"
```Now you can use josa crate.
```rust
use josa::*;
// Use here..
```## Documentation
See [docs.rs][documentation]## Roadmap
### `select` macro
As soon as [hygiene 2.0 (#54727)][hygiene] arrives stable, we will add support for following macro:```rust
select!("{}{은} {}{가} 먹고싶다", user, mackerel);
```which is terser than current syntax:
### Hangul enum variants
As soon as [non-ASCII identifiers (#55467)][ident] arrives stable, we will change the names of josas to Hangul:```rust
format!("{} {} 먹고싶다", user + 은는, mackerel + 이가);
```## License
Distributed under the MIT license.[version]: https://img.shields.io/crates/v/josa
[license]: https://img.shields.io/crates/l/josa
[download]: https://img.shields.io/crates/d/josa[Rust]: https://rust-lang.org
[extension trait]: https://github.com/rust-lang/rfcs/blob/master/text/0445-extension-trait-conventions.md
[`String`]: https://doc.rust-lang.org/std/string/struct.String.html
[`str`]: https://doc.rust-lang.org/std/primitive.str.html
[`push_str`]: https://doc.rust-lang.org/std/string/struct.String.html#method.push_str[documentation]: https://docs.rs/josa
[hygiene]: https://github.com/rust-lang/rust/issues/54727
[ident]: https://github.com/rust-lang/rust/issues/55467