Skip to content

Commit 164669a

Browse files
committed
Change merge to conj (and add test to meta)
1 parent d16acb8 commit 164669a

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/persistent_list_map.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ macro_rules! persistent_list_map {
6363
}
6464
};
6565
}
66-
67-
/// merge!(base_meta(name, ns), map_entry!("key1", "value1"), map_entry!("key2", "value2"));
66+
/// Just like conj in Clojure, conj allows you to conjoin a new mapentry onto a map
67+
/// although currently, that is all it allows
68+
/// conj!(base_meta(name, ns), map_entry!("key1", "value1"), map_entry!("key2", "value2"));
6869
#[macro_export]
69-
macro_rules! merge {
70+
macro_rules! conj {
7071
( $plistmap:expr, $($kv:expr), *) => {
7172
{
7273
let mut temp_plistmap_as_vec = $plistmap.clone().iter().collect::<Vec<MapEntry>>();

src/reader.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ pub fn try_read_meta(input: &str) -> IResult<&str, Value> {
512512
let column = 1;
513513
// @TODO merge the meta iobj_value *already* has
514514
// @TODO define some better macros and / or functions for map handling
515-
meta = merge!(
515+
meta = conj!(
516516
meta,
517517
map_entry!("line",line),
518518
map_entry!("column",column)
@@ -990,6 +990,17 @@ mod tests {
990990
}
991991
}
992992
#[test]
993+
fn try_read_multiple_meta_keyword() {
994+
let with_meta = "^:cat ^:dog a";
995+
match try_read(with_meta).ok().unwrap().1 {
996+
Value::Symbol(symbol) => {
997+
assert!(symbol.meta().contains_key(&Keyword::intern("cat").to_rc_value()));
998+
assert!(symbol.meta().contains_key(&Keyword::intern("dog").to_rc_value()));
999+
},
1000+
_ => panic!("try_read_meta \"^:cat a\" should return a symbol")
1001+
}
1002+
}
1003+
#[test]
9931004
fn try_read_meta_keyword() {
9941005
let with_meta = "^:cat a";
9951006
match try_read(with_meta).ok().unwrap().1 {

src/symbol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ mod tests {
197197
"namespace",
198198
"name"
199199
).with_meta(
200-
merge!(
200+
conj!(
201201
PersistentListMap::Empty,
202202
map_entry!("key", "value")
203203
)
204204
),
205205
Symbol {
206206
ns: String::from("namespace"),
207207
name: String::from("name"),
208-
meta: merge!(
208+
meta: conj!(
209209
PersistentListMap::Empty,
210210
map_entry!("key", "value")
211211
)

src/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl Value {
354354
let ss = Symbol::intern_with_ns(
355355
&sym.ns,
356356
&sym.name
357-
// merge!(
357+
// conj!(
358358
// meta::base_meta(&sym.ns, &sym.name),
359359
// map_entry!("doc", doc_string)
360360
// ),

0 commit comments

Comments
 (0)