rdickert
rdickert
Explore posts from servers
TTCTheo's Typesafe Cult
Created by rdickert on 6/27/2024 in #questions
Using nextauth discord with vercel deployments
New to T3 and nextauth here, and I have a noob question: If I configure discord oauth, discord requires me to register exact URIs for login redirects, but Vercel deployments have dynamic URIs for each branch, so a new branch deployment will never match. I can get any deployment to work by manually adding its URL to the discord app management page, but is there a way to make it work for any vercel branch? If not, do you have a preferred workaround/working style that you think is most effective? Maybe I should just use username/pw login for branches
8 replies
MModular
Created by rdickert on 1/1/2024 in #questions
Passing generics to DynamicVector
I'm trying to understand the traits system and am working with a toy list struct from this thread The original declaration (which works) starts with:
@value
struct list[T: CollectionElement](Sized):
var _internal_vector: DynamicVector[T]
@value
struct list[T: CollectionElement](Sized):
var _internal_vector: DynamicVector[T]
In the above I can declare a list of strings with list[String] I have tried to add the ability to print items in the list, but CollectionElements aren't accepted by str (errors with "no matching function in call to 'str'"), so I tried making a trait that inherits from both requirements:
trait ListElement(CollectionElement, Stringable):
...

@value
struct list[T: ListElement](Sized):
trait ListElement(CollectionElement, Stringable):
...

@value
struct list[T: ListElement](Sized):
This removes the compile error in my print method, but then I can no longer declare list[String]. In this declaration
fn read_strings_from_file(file_name: String) raises -> list[String]:
fn read_strings_from_file(file_name: String) raises -> list[String]:
the compiler errors with "'list' parameter #0 has 'ListElement' type, but value has type 'String'". But it seems like String should satisfy my new trait since it satisfied CollectionElement and should certainly satisfy Stringable. Am I doing something wrong, or is this a current bug/limitation of Mojo?
1 replies
MModular
Created by rdickert on 11/27/2023 in #questions
Errors for flow control?
Exceptions are used for flow control in Python (e.g. the StopIteration exception). Is this considered a good/normal practice in mojo as well (using Error I guess)?
3 replies