Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## next

- Fixed bug where `InlineTable` could not be cast `as_table`.

## v1.1.0 - 2024-09-23

- Added the `as_array`, `as_bool`, `as_date`, `as_date_time`, `as_float`,
Expand Down
1 change: 1 addition & 0 deletions src/tom.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,7 @@ pub fn as_array(toml: Toml) -> Result(List(Toml), GetError) {
pub fn as_table(toml: Toml) -> Result(Dict(String, Toml), GetError) {
case toml {
Table(tbl) -> Ok(tbl)
InlineTable(tbl) -> Ok(tbl)
other -> Error(WrongType([], "Table", classify(other)))
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/tom_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,9 @@ pub fn tom_as_table_test() {
tom.as_table(tom.Table(dict))
|> should.equal(Ok(dict))

tom.as_table(tom.InlineTable(dict))
|> should.equal(Ok(dict))

tom.as_table(tom.Int(1))
|> should.equal(Error(tom.WrongType([], "Table", "Int")))
}
Expand Down
Loading