Parse labelled configuration and customise record prefixes
This commit is contained in:
2 files changed
+57
-5
No files matched your search
@@ -69,3 +69,17 @@ let () =
|
||||
assert (Prefixed.red Prefixed.{ paint_colour_red = 3; paint_colour_green = 4 } = 3);
|
||||
assert (Unprefixed.yes Unprefixed.{ yes = true; yellow = false });
|
||||
assert (Single.paint_red Single.{ paint_red = 3 } = 3)
|
||||
|
||||
module Named = struct
|
||||
type t = { item_colour : string; item_size : int }
|
||||
[@@fieldglass generate ~field_prefix:swatch]
|
||||
end
|
||||
|
||||
module Typed = struct
|
||||
type swatch = { item_colour : string; item_size : int }
|
||||
[@@fieldglass generate ~field_prefix_from_type]
|
||||
end
|
||||
|
||||
let () =
|
||||
assert (Named.swatch_colour Named.{ item_colour = "grey"; item_size = 3 } = "grey");
|
||||
assert (Typed.swatch_size Typed.{ item_colour = "grey"; item_size = 3 } = 3)
|
||||
Reference in new issue
Block a user