Skip to content

Commit 56d55e0

Browse files
authored
Use to_doc when converting algebra documents (#10)
Elixir v1.19 allows the inspect protocol to return a tuple {doc, opts}, so we use the official to_doc API for converting documents. This is backwards compatible.
1 parent d436da5 commit 56d55e0

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/pgvector.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,6 @@ defimpl Inspect, for: Pgvector do
135135
import Inspect.Algebra
136136

137137
def inspect(vector, opts) do
138-
concat(["Pgvector.new(", Inspect.List.inspect(Pgvector.to_list(vector), opts), ")"])
138+
concat(["Pgvector.new(", to_doc(Pgvector.to_list(vector), opts), ")"])
139139
end
140140
end

lib/pgvector/half_vector.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ defimpl Inspect, for: Pgvector.HalfVector do
5050
import Inspect.Algebra
5151

5252
def inspect(vector, opts) do
53-
concat(["Pgvector.HalfVector.new(", Inspect.List.inspect(Pgvector.to_list(vector), opts), ")"])
53+
concat(["Pgvector.HalfVector.new(", to_doc(Pgvector.to_list(vector), opts), ")"])
5454
end
5555
end

lib/pgvector/sparse_vector.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ defimpl Inspect, for: Pgvector.SparseVector do
101101

102102
concat([
103103
"Pgvector.SparseVector.new(",
104-
Inspect.Map.inspect(elements, opts),
104+
to_doc(elements, opts),
105105
", ",
106-
Inspect.Integer.inspect(dimensions, opts),
106+
to_doc(dimensions, opts),
107107
")"
108108
])
109109
end

0 commit comments

Comments
 (0)