Skip to content

Commit 9b56cca

Browse files
committed
Fix a small bug with to_s.
1 parent 33aa514 commit 9b56cca

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

shard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: csuuid
2-
version: 0.2.2
2+
version: 0.2.3
33

44
authors:
55
- Kirk Haines <[email protected]>

spec/csuuid_spec.cr

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ describe CSUUID do
88
uuid.to_s.should match CHECKUUID
99
end
1010

11+
it "to_s should function correctly" do
12+
uuid = CSUUID.new
13+
uuid.to_s.should eq "#{uuid}"
14+
end
15+
1116
it "creates a UUID from another UUID" do
1217
uuid_1 = CSUUID.new
1318
uuid_2 = CSUUID.new(uuid_1)

src/csuuid.cr

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ require "crystal/spin_lock"
4040
# ```
4141
#
4242
struct CSUUID
43-
VERSION = "0.2.2"
43+
VERSION = "0.2.3"
4444

4545
@@mutex = Crystal::SpinLock.new
4646
# @@mutex = Mutex.new(protection: Mutex::Protection::Reentrant)
@@ -164,8 +164,8 @@ struct CSUUID
164164
end
165165

166166
# Return the String representation of the UUID.
167-
def to_s : String
167+
def to_s(io : IO) : Nil
168168
hs = @bytes.hexstring
169-
"#{hs[0..7]}-#{hs[8..11]}-#{hs[12..15]}-#{hs[16..19]}-#{hs[20..31]}"
169+
io << "#{hs[0..7]}-#{hs[8..11]}-#{hs[12..15]}-#{hs[16..19]}-#{hs[20..31]}"
170170
end
171171
end

0 commit comments

Comments
 (0)