Repository: vapor/vapor
File: Sources/Vapor/HTTP/Headers/HTTPHeaders+ContentRange.swift (Swift)

Code before:
        }
        
        public func serialize() -> String {
            return "\(unit.serialize()) \(range.serialize())"
        }
        
    }
    
    /// Convenience for accessing the Content-Range response header.
    ///
    /// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range
    public var contentRange: ContentRange? {
        get {
            let directives = parseDirectives(name: .contentRange).flatMap { $0 }
            return HTTPHeaders.ContentRange(directives: directives)
        }
        set {
            if contains(name: .contentRange) {
                remove(name: .contentRange)
            }
            if newValue == nil {
                return
            }
            add(name: .contentRange, value: newValue!.serialize())
        }
    }
    
    /// Convenience for accessing the `Range` request header.
    ///
    /// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range
    public var range: Range? {
        get {
            return HTTPHeaders.Range(directives: self.parseDirectives(name: .range).flatMap { $0 })
        }
        set {
            if contains(name: .range) {
                remove(name: .range)
            }
            if newValue == nil {
                return
            }
            add(name: .range, value: newValue!.serialize())
        }
    }
}

extension HTTPHeaders.Range {
    /// Represents one value of the `Range` request header.
    ///
    /// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range
    public enum Value: Equatable {

Review comment (suggestion):
- Add a couple of `self`s to be in compliance with [the style guide](https://github.com/vapor/vapor/blob/master/.github/contributing.md)
- write getter in same style as for `range`
- use guard to avoid force unwrap
```suggestion
    public var contentRange: ContentRange? {
        get {
            return HTTPHeaders.ContentRange(directives: self.parseDirectives(name: .contentRange).flatMap { $0 })
        }
        set {
            if self.contains(name: .contentRange) {
                self.remove(name: .contentRange)
            }
            guard let newValue == newValue else {
                return
            }
            self.add(name: .contentRange, value: newValue.serialize())
        }
    }
```

Code after:
        }
        
        public func serialize() -> String {
            return "\(unit.serialize()) \(range.serialize())"
        }
        
    }
    
    /// Convenience for accessing the Content-Range response header.
    ///
    /// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range
    public var contentRange: ContentRange? {
        get {
            return HTTPHeaders.ContentRange(directives: self.parseDirectives(name: .contentRange).flatMap { $0 })
        }
        set {
            if self.contains(name: .contentRange) {
                self.remove(name: .contentRange)
            }
            guard let newValue = newValue else {
                return
            }
            self.add(name: .contentRange, value: newValue.serialize())
        }
    }
    
    /// Convenience for accessing the `Range` request header.
    ///
    /// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range
    public var range: Range? {
        get {
            return HTTPHeaders.Range(directives: self.parseDirectives(name: .range).flatMap { $0 })
        }
        set {
            if self.contains(name: .range) {
                self.remove(name: .range)
            }
            guard let newValue = newValue else {
                return
            }
            self.add(name: .range, value: newValue.serialize())
        }
    }
}

extension HTTPHeaders.Range {
    /// Represents one value of the `Range` request header.
    ///
    /// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range
    public enum Value: Equatable {
        ///Integer with single trailing dash, e.g. `25-`