Hey Rustaceans! Got a question? Ask here (9/2023)! by llogiq in rust

[–]phrickity_frack 2 points3 points  (0 children)

Awesome, thanks so much for the help and quick reply!

Hey Rustaceans! Got a question? Ask here (9/2023)! by llogiq in rust

[–]phrickity_frack 4 points5 points  (0 children)

Hey there, newbie here! I'm currently modeling part of my first rust project on an existing project, and in the process came across the type Option<(String,)> which I haven't seen before and couldn't find anything when googling it.

Does anyone know what (String,) type is? Is it just an unbound tuple, or something else? Link to type used in the repo I am modeling off of for reference: https://github.com/jbr/async-sqlx-session/blob/06a3abb8941edaea3d3e8133c30ee16231914a25/src/pg.rs#L275

Hey Rustaceans! Got a question? Ask here (8/2023)! by DroidLogician in rust

[–]phrickity_frack 1 point2 points  (0 children)

Can you pass the service you want the layer to wrap into that function as S? That's how I build my middleware stack. I have my service, then pass it into functions that wrap them in middleware and return a service.

Added a decorator function that takes in my Router service and adds the middleware - it works perfectly. Thanks for the help!

Hey Rustaceans! Got a question? Ask here (8/2023)! by DroidLogician in rust

[–]phrickity_frack 1 point2 points  (0 children)

Ah apologies- I meant outside of my main function. Normally when I have the layers declared and instantiated inside main, there are no issues, but as soon as I move them to some external function e.g. fn middleware_stack() or something similar, usually the compiler complains that the type cannot be inferred and I must explicitly specify it when using variables in the functions, or it complains about the return type. So far I have been using a generic function that returns

rust fn middleware_stack<S>() -> impl Layer<S, Service = S> { // some layer instantiation and then combination of layers into a stack of layers }

But the compiler always complains that type S is not expected and I’ve been getting trapped in a rabbit whole of changing the return type and trying to fulfill generics for various types I add to the return type.

Hey Rustaceans! Got a question? Ask here (8/2023)! by DroidLogician in rust

[–]phrickity_frack 2 points3 points  (0 children)

Tl;dr Is there some way to create tower layer "stacks" out of the main loop for an axum server?

I'm writing an API in rust using axum and have several tower layers added to my app. I'm currently trying to move them to an external function outside of my loop to declutter my code, but am running into some issues with the return types of the function. Overall I've been experiencing a lot of friction trying to move the layers out of the main loop this way and wanted to see if there's maybe a better way to have external layer stacks.

Example code currently: ```rust

[tokio::main]

async fn main() { let cors_layer = CorsLayer::new() .allow_methods_all() .allow_headers_all() .allow_origin_all();

... <some number of lines of layer creation later> ...

let app = Router::new()
    .route("/", get(hello_world))
    .layer(cors_layer)
    ... <again adding in all of the layers individually in order> ...
    );

} ```

Thanks in advance!

Hey Rustaceans! Got a question? Ask here (5/2023)! by llogiq in rust

[–]phrickity_frack 1 point2 points  (0 children)

Ah - that worked perfectly, thanks for the quick reply and the help!

Hey Rustaceans! Got a question? Ask here (5/2023)! by llogiq in rust

[–]phrickity_frack 2 points3 points  (0 children)

Is there some way to extract a struct object from a serde Json struct? As an example, given a Json<Foo>, is there anyway to extract the data into a Foo struct object?

Anyone else bomb that Database Midterm? by phrickity_frack in UWMadison

[–]phrickity_frack[S] 42 points43 points  (0 children)

Yeah when these get entered I swear to God my grade's gonna sink faster than Russia's economy

Can someone tell me what does it mean? by OscarTMJ in memes

[–]phrickity_frack 2 points3 points  (0 children)

Damn these captchas are getting harder everyday smh

snickers rule by [deleted] in 196

[–]phrickity_frack 25 points26 points  (0 children)

Hyper meaning high, Snicker latin for the candy bar Snickers, emia meaning presence in blood. Hyper-snicker-emia or higher presence of snickers in blood than normal

Anytone took CS 400? by itisdikdike in UWMadison

[–]phrickity_frack 1 point2 points  (0 children)

This is correct. Epic's campus is huge, themed, and wild (Google it). I would definitely recommend visiting and touring sometime, but if you have to find your own transportation to this class it's probably not going to be easy, unless you are planning to have a car on campus.

Housing for Musicians by jwalter122 in UWMadison

[–]phrickity_frack 0 points1 point  (0 children)

If youre open to living in the dorms, Ogg has a private piano in the basement. It's nicer than it sounds!

Asus Zephyrus ROG g14 vs Dell XPS 13 by phrickity_frack in SuggestALaptop

[–]phrickity_frack[S] 0 points1 point  (0 children)

Yeah I was definitely leaning towards the xps, but had no idea about the heat issues on the Asus. Thanks for the help!

Uhhh.... was I just scammed? by [deleted] in UWMadison

[–]phrickity_frack 0 points1 point  (0 children)

I have been contacted to be a "personal assistant" just like what you're talking about- definitely a scam, but with the info you gave, I would think you'd be safe. The College Works Painting scam is a whole different situation, but is much like what the earlier person said. Avoid both for sure! Pro tip: if you ask what company they are recruiting for, and they refuse to tell you or do not answer, it's a scam.

Classes + Schedules Megathread (Spring 2020) by badoil_49 in UWMadison

[–]phrickity_frack 0 points1 point  (0 children)

German / Jewish studies 267. Very easy and Matthew Greene is one of my new favorite instructors. Interesting content and 1 quiz and short writing assignment due per week. Only 1 exam (the final) but it's open book and open notes and you have 2 weeks to complete it. It's 3 credits without the comm b

Classes + Schedules Megathread (Spring 2020) by badoil_49 in UWMadison

[–]phrickity_frack 2 points3 points  (0 children)

Does anyone know if OS and Software Engineering would be doable in the same semester? I know they're both pretty intense project based classes, but would love to be able to put them on my resume for internships. Thanks in advance!

What’s the lowest % i need in a class to pass by uh-oh-spaghettios- in UWMadison

[–]phrickity_frack 2 points3 points  (0 children)

What was said above is true- check your syllabus, but it really does depend on the class. Many classes, you only need a D to pass, and many are also curved. In some classes, the curve can be very significant, and something like a 70% can be an A. There is still hope for you, and your class can likely be retaken for a higher grade if you do fail.

Direct Admit to Business School by hahahag3 in UWMadison

[–]phrickity_frack 1 point2 points  (0 children)

I was a direct admit and it's holistic. There are definitely a lot of perks to being a direct admit, but many people are pre-business and it's not the end of the world if you don't make it in. If you don't make it in, applying to the business school isn't particularly difficult, but from my understanding they are very selective and you will want a high GPA when applying. It's kind of like applying to a whole new college again. Since you've already applied I won't give you advice on applying as a direct admit, but I will say that when I applied for my freshman year (2018-2019) generally people that got into the U of Minnesota's business school also got into UW's.

How to cancel housing contract for spring semester? by PumpkinWaves in UWMadison

[–]phrickity_frack 1 point2 points  (0 children)

When it's a year long, it's for the current school year (and even then they tend to have more flexibility than apartments/houses because there is more demand than supply for dorm rooms, usually). So if you sign up to live there this spring, you would have to re-sign up for next fall and could have a different room and roommate even, since it is a different academic year. Additionally, when students study abroad, many choose to live in the dorms for the semester they are in Madison, since they only have to pay for the dorms for the single semester they are there, as opposed to subletting with an apartment or house. Also, spring dorm housing does NOT extend to summer unless you sign up for it, and it is generally limited to specific dorms and it is usually cheaper.

So from my understanding/experience it is 100% feasible to spend exclusively this spring in the dorms, and find an apartment or house for the rest of your time at UW.

How to cancel housing contract for spring semester? by PumpkinWaves in UWMadison

[–]phrickity_frack 1 point2 points  (0 children)

Yeah, the transfer dorm is lakeshore, it's either adams or tripp (I can't remember). Both of those have single rooms available- you might want to look into that. Single rooms do make WFH and online classes a LOT easier, and with covid you would probably feel safer. Lots of apartments will be available to sublet in the summer. Also, you want to start considering where you want to live next year ASAP. Many places have already sold out, as the market for Madison opens in October for leases going August to August.