Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kayak UI
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Forks
Kayak UI
Commits
34a4b7dc
Commit
34a4b7dc
authored
3 years ago
by
Gino Valente
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup methods
parent
c542124c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kayak_core/src/tree.rs
+10
-26
10 additions, 26 deletions
kayak_core/src/tree.rs
with
10 additions
and
26 deletions
kayak_core/src/tree.rs
+
10
−
26
View file @
34a4b7dc
...
...
@@ -501,38 +501,22 @@ impl Tree {
}
pub
fn
get_next_sibling
(
&
self
,
index
:
Index
)
->
Option
<
Index
>
{
if
let
Some
(
parent_index
)
=
self
.get_parent
(
index
)
{
self
.children
.get
(
&
parent_index
)
.map_or
(
None
,
|
children
|
{
children
.iter
()
.position
(|
child
|
*
child
==
index
)
.map_or
(
None
,
|
child_index
|
{
children
.get
(
child_index
+
1
)
.map_or
(
None
,
|
next_child
|
Some
(
*
next_child
))
})
})
let
order
=
self
.get_sibling_order
(
index
);
if
let
Some
(
children
)
=
self
.get_children
(
index
)
{
children
.get
(
order
+
1
)
.map
(|
sibling
|
*
sibling
)
}
else
{
None
}
}
pub
fn
get_prev_sibling
(
&
self
,
index
:
Index
)
->
Option
<
Index
>
{
if
let
Some
(
parent_index
)
=
self
.get_parent
(
index
)
{
self
.children
.get
(
&
parent_index
)
.map_or
(
None
,
|
children
|
{
children
.iter
()
.position
(|
child
|
*
child
==
index
)
.map_or
(
None
,
|
child_index
|
{
if
child_index
>
0
{
children
.get
(
child_index
-
1
)
.map_or
(
None
,
|
prev_child
|
Some
(
*
prev_child
))
}
else
{
None
}
})
})
let
order
=
self
.get_sibling_order
(
index
);
if
order
==
0
{
return
None
;
}
if
let
Some
(
children
)
=
self
.get_children
(
index
)
{
children
.get
(
order
-
1
)
.map
(|
sibling
|
*
sibling
)
}
else
{
None
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment