Skip to content

Commit

Permalink
Remove the IntoPath trait
Browse files Browse the repository at this point in the history
This trait isn't really useful given we already have ToPath. It also
makes it more difficult to choose between taking a Path, ToPath, or
IntoPath as an argument type.

See #632 for more details.

Changelog: changed
  • Loading branch information
yorickpeterse committed Feb 15, 2024
1 parent ddd6040 commit 4047c8b
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 31 deletions.
2 changes: 1 addition & 1 deletion std/src/std/env.inko
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn pub home_directory -> Option[Path] {
#
# env.temporary_directory # => '/tmp'
fn pub temporary_directory -> Path {
inko_env_temp_directory(_INKO.state).into_path
Path.new(inko_env_temp_directory(_INKO.state))
}

# Returns the current working directory.
Expand Down
15 changes: 0 additions & 15 deletions std/src/std/fs/path.inko
Original file line number Diff line number Diff line change
Expand Up @@ -889,15 +889,6 @@ trait pub ToPath {
fn pub to_path -> Path
}

# A type that can be moved into a `Path`
#
# `IntoPath` is useful when you want to accept any type that can be converted to
# a `Path`, including a `Path` itself, but don't unnecessary allocations.
trait pub IntoPath {
# Moves `self` into a `Path`.
fn pub move into_path -> Path
}

impl Equal[ref Path] for Path {
# Returns `true` if `self` is equal to the given `Path`.
#
Expand Down Expand Up @@ -971,12 +962,6 @@ impl ToPath for Path {
}
}

impl IntoPath for Path {
fn pub move into_path -> Path {
self
}
}

impl Format for Path {
fn pub fmt(formatter: mut Formatter) {
@path.fmt(formatter)
Expand Down
8 changes: 1 addition & 7 deletions std/src/std/string.inko
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import std.clone.Clone
import std.cmp.(Contains, Equal)
import std.drop.Drop
import std.fmt.(Format, Formatter)
import std.fs.path.(IntoPath, Path, ToPath)
import std.fs.path.(Path, ToPath)
import std.hash.(Hash, Hasher)
import std.io.Read
import std.iter.(Stream, Iter)
Expand Down Expand Up @@ -770,12 +770,6 @@ impl ToPath for String {
}
}

impl IntoPath for String {
fn pub move into_path -> Path {
Path.new(self)
}
}

impl Format for String {
fn pub fmt(formatter: mut Formatter) {
formatter.write('"')
Expand Down
4 changes: 0 additions & 4 deletions std/test/std/fs/test_path.inko
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ fn pub tests(t: mut Tests) {
t.equal(Path.new('foo').to_path, Path.new('foo'))
}

t.test('Path.into_path') fn (t) {
t.equal(Path.new('foo').into_path, Path.new('foo'))
}

t.test('Path.fmt') fn (t) {
t.equal(fmt(Path.new('foo')), '"foo"')
}
Expand Down
4 changes: 0 additions & 4 deletions std/test/std/test_string.inko
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,6 @@ fn pub tests(t: mut Tests) {
t.equal('foo.inko'.to_path, Path.new('foo.inko'))
}

t.test('String.into_path') fn (t) {
t.equal('foo'.into_path, Path.new('foo'))
}

t.test('String.escaped') fn (t) {
t.equal('foo'.escaped, 'foo')
t.equal('"foo"'.escaped, '\"foo\"')
Expand Down

0 comments on commit 4047c8b

Please sign in to comment.