Skip to content

Commit

Permalink
Doc warn and warn_with (#23441)
Browse files Browse the repository at this point in the history
* Doc warn and warn_with
  • Loading branch information
kshyatt authored Aug 29, 2017
1 parent 15fb3db commit 109b0b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion base/libgit2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -956,8 +956,12 @@ The fields represent:
boundary::Char
end

"""
with(f::Function, obj)
""" Resource management helper function
Resource management helper function. Applies `f` to `obj`, making sure to call
`close` on `obj` after `f` successfully returns or throws an error. Ensures that
allocated git resources are finalized as soon as they are no longer needed.
"""
function with(f::Function, obj)
try
Expand All @@ -969,6 +973,15 @@ end

with(f::Function, ::Type{T}, args...) where {T} = with(f, T(args...))

"""
with_warn(f::Function, ::Type{T}, args...)
Resource management helper function. Apply `f` to `args`, first constructing
an instance of type `T` from `args`. Makes sure to call `close` on the resulting
object after `f` successfully returns or throws an error. Ensures that
allocated git resources are finalized as soon as they are no longer needed. If an
error is thrown by `f`, a warning is shown containing the error.
"""
function with_warn(f::Function, ::Type{T}, args...) where T
obj = T(args...)
try
Expand Down
1 change: 1 addition & 0 deletions doc/src/devdocs/libgit2.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,6 @@ Base.LibGit2.update!
Base.LibGit2.url
Base.LibGit2.version
Base.LibGit2.with
Base.LibGit2.with_warn
Base.LibGit2.workdir
```

0 comments on commit 109b0b4

Please sign in to comment.