无法使用类型为“(from: T, to: T, by: T)”的参数列表调用 'stride' Swift

Cannot invoke 'stride' with an argument list of type '(from: T, to: T, by: T)' Swift

我正在尝试创建一个适用于 Integer 和 Double 的通用函数。但是有些错误 Cannot invoke 'stride' with an argument list of type '(from: T, to: T, by: T)'。 下面是我的代码:

func generateList<T: SignedNumeric>(from: T, to: T, step: T, addLastValue: Bool = true) -> [T] where T: Comparable & Strideable {
        var items = [T]()

        if step == 0 || from == to {
            return [from]
        }

        for i in stride(from: from, to: to, by: step) {
            items.append(i)
        }

        if addLastValue && to > items.last ?? to {
            items.append(to)
        }

        return items
    }

步骤必须为 T.Stride

类型
func generateList<T: SignedNumeric>(from: T, to: T, step: T.Stride, addLastValue: Bool = true) -> [T] where T: Comparable & Strideable {
    var items = [T]()

    if step == 0 || from == to {
        return [from]
    }

    for i in stride(from: from, to: to, by: step) {
        items.append(i)
    }

    if addLastValue && to > items.last ?? to {
        items.append(to)
    }

    return items
}