 
  @return [Mention]: A new mention array
  */
-internal func adjusted(forTextChangeAt range: NSRange, text: String) -> (inout [Mention]) -> Void {
+internal func adjusted(forTextChangeAt range: NSRange, text: String) -> ([Mention]) -> [Mention] {
     return { mentions in
         let remainingLengthOfMention = text.utf16.count - range.length
-        mentions = mentions.compactMap { mention in
+        return mentions.compactMap { mention in
             guard mention.range.location >= NSMaxRange(range) else { return mention }
             var adjustedMention = mention
             adjustedMention.range.location += remainingLengthOfMention


 @return [Mention]: A new mention array
 */
internal func add(_ mention: CreateMention, spaceAfterMention: Bool, at range: NSRange) -> (inout [Mention]) -> Void {
    return { mentions in
        let adjustedRange = range.adjustLength(for: mention.name)
        mentions |> adjusted(forTextChangeAt: range,
                             text: mention.mentionName(with: spaceAfterMention))
        mentions |> insert([(mention, adjustedRange)])
    }
}


 @return [Mention]: A new mention array
 */
internal func remove(_ mentionsToRemove: [Mention]) -> ([Mention]) -> [Mention] {
    return { mentions in
        mentions.filter { !mentionsToRemove.contains($0) }
    }
}

