blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
140
path
stringlengths
5
183
src_encoding
stringclasses
6 values
length_bytes
int64
12
5.32M
score
float64
2.52
4.94
int_score
int64
3
5
detected_licenses
listlengths
0
47
license_type
stringclasses
2 values
text
stringlengths
12
5.32M
download_success
bool
1 class
83eaa72cd975ef7cfe56276db422fd41175639d3
Rust
SINHASantos/tauri
/core/tauri/src/api/shell.rs
UTF-8
3,166
3.015625
3
[ "Apache-2.0", "CC0-1.0", "MIT", "CC-BY-NC-ND-4.0" ]
permissive
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT //! Types and functions related to shell. use crate::ShellScope; use std::str::FromStr; /// Program to use on the [`open()`] call. pub enum Program { /// Use the `open` progr...
true
fe046733191cc07ed7d3c39dcd63961c1c1cba07
Rust
nuta/noa
/src/noa/views/metaline_view.rs
UTF-8
4,620
2.59375
3
[ "Apache-2.0", "MIT" ]
permissive
use noa_buffer::display_width::DisplayWidth; use noa_compositor::{ canvas::CanvasViewMut, surface::{Layout, RectSize, Surface}, }; use crate::{ config::theme_for, editor::Editor, notification::{notification_manager, Notification}, }; use super::truncate_to_width_suffix; pub const META_LINE_HEIGHT...
true
79d401aff9e515079bd0b07a1fa2d4c74a72ff9d
Rust
pjmore/arrow2
/src/array/equal/boolean.rs
UTF-8
1,270
2.765625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate::{array::BooleanArray, bitmap::Bitmap}; use super::utils::{count_validity, equal_bits}; pub(super) fn equal( lhs: &BooleanArray, rhs: &BooleanArray, lhs_validity: &Option<Bitmap>, rhs_validity: &Option<Bitmap>, lhs_start: usize, rhs_start: usize, len: usize, ) -> bool { let l...
true
f88455e37ddb56abe167cba81c4d66da875bf64e
Rust
ArielMant0/RustChess
/src/system.rs
UTF-8
6,719
2.78125
3
[ "MIT" ]
permissive
// MIT License // // Copyright (c) 2017 Franziska Becker, René Warking // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to...
true
3cd9a716a855fb93368cc30a3e8d1473433894b0
Rust
unity-haiwei/test
/dashboard/src/logic/project.rs
UTF-8
2,570
2.84375
3
[]
no_license
use core::ops::Add; use bson; use bson::oid::ObjectId; use chrono::{UTC}; use chrono::duration::Duration; use config; use utils; use db::{self, DBTrait}; use Runtime; use super::LogicTrait; #[derive(Clone)] pub struct Project<'a> { runtime: &'a Runtime, db: db::Project, db_user: db::User, } impl<'a> Pr...
true
309483a8c4885613fa80932cb5437f1e2e58c249
Rust
fbrv/youki
/crates/libcontainer/src/namespaces.rs
UTF-8
7,128
2.9375
3
[ "Apache-2.0" ]
permissive
//! Namespaces provide isolation of resources for processes at a kernel level. //! The namespaces are: Mount (filesystem), //! Process (processes in a namespace have two PIDs, one for the global PID, //! which is used by the main system and the second one is for the child within the process tree), //! Interprocess Comm...
true
bfa03face2bbdf878527107db02b40367391844a
Rust
linebender/piet
/piet-common/src/lib.rs
UTF-8
2,585
3.046875
3
[ "Apache-2.0", "MIT" ]
permissive
//! A piet backend appropriate for the current platform. //! //! This crate reexports the [piet crate][piet], alongside an appropriate backend //! for the given platform. It also exposes [kurbo], which defines shape and //! curve types useful in drawing, and [image] for image manipulation. //! //! The intention of this...
true
3ce3cfee5df8a57fb9bbba9b402b69782a1c5a05
Rust
TGElder/rust
/frontier/src/world/vegetation.rs
UTF-8
2,295
3.0625
3
[ "CC-BY-4.0" ]
permissive
use serde::{Deserialize, Serialize}; pub const VEGETATION_TYPES: [VegetationType; 5] = [ VegetationType::SnowTree, VegetationType::EvergreenTree, VegetationType::DeciduousTree, VegetationType::PalmTree, VegetationType::Cactus, ]; #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, S...
true
2d3b6438ebd98a6647b8cc3722c1bf8365c34f64
Rust
royswale/leetcode
/src/bin/coin-change.rs
UTF-8
1,150
3.25
3
[ "MIT" ]
permissive
fn main() { println!("{}", Solution::coin_change(vec![1, 2, 5], 11)); println!("{}", Solution::coin_change(vec![1], 1)); println!("{}", Solution::coin_change(vec![1, 2, 5], 100)); } struct Solution; impl Solution { pub fn coin_change(coins: Vec<i32>, amount: i32) -> i32 { if amount == 0 { ...
true
b28aa6040900b68a0bbd15c59be4a46d1487a502
Rust
jameslzhu/alpm
/libalpm/src/log.rs
UTF-8
4,242
3.109375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Logging in libalpm use std::default::Default; use std::fmt; use std::cmp::{self, Ordering}; use alpm_sys::*; /// The highest log level marked true #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum LogLevel { Error, Warning, Debug, Function, None } impl cmp::Ord for LogLevel { fn cmp(...
true
2ea7e0fc7f322cb32e6f0ff8ba1664a5eb2e7005
Rust
mzabaluev/generic-tests
/tests/async.rs
UTF-8
1,927
2.640625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![cfg(feature = "test-tokio")] #![deny(unused)] #![warn(clippy::all)] #[generic_tests::define(attrs(tokio::test))] mod async_tests { use bytes::{Buf, Bytes}; use tokio::io::{self, AsyncWrite, AsyncWriteExt, Error}; use std::pin::Pin; use std::task::{Context, Poll}; #[tokio::test] async fn as...
true
e36c9b0ef8e994d5c558d950955eea444986da91
Rust
tuzz/supersat
/src/rank/mod.rs
UTF-8
1,394
3.171875
3
[]
no_license
use std::ops::Range; use crate::variable::Variable; use crate::formula::Formula; use crate::state::State; #[derive(Debug, Eq, PartialEq)] pub struct Rank { variables: Vec<Variable>, states: Vec<State>, } impl Rank { pub fn new(number_of_states: usize, formula: &mut Formula) -> Self { let number_o...
true
91e78b6705c877e7d42b2e38d0fd1a5e5c21289e
Rust
tonyastolfi/lbb-trees
/src/leaf.rs
UTF-8
921
2.640625
3
[]
no_license
use itertools::Itertools; use super::block_cache::BlockCache; use super::item::Item; use super::msg::Msg; use super::update::Update; pub struct Leaf<K, V> { pub items: Vec<Item<K, V>>, } impl<K, V> Leaf<K, V> { pub fn batch_update<B, M: Msg<Val = V>>(&self, batch: B) -> Leaf<K, V> where K: Eq + O...
true
8bbf6f8f7266f8cd32d1eb6b0314508d75424c22
Rust
aesterline/aoc2018
/src/day1.rs
UTF-8
3,061
3.59375
4
[]
no_license
use std::collections::HashSet; use std::io::{BufRead, Result, Seek, SeekFrom}; pub fn frequency<T>(changes: T) -> Result<i64> where T: BufRead, { // changes.lines().fold(Ok(0), |result, change| { // Ok(result? + change?.parse::<i64>().unwrap()) // }) let mut result = 0; for line in changes...
true
9197ce1cf8e4c09e62541e5f1165c76599b1070b
Rust
auto-impl-rs/auto_impl
/examples/keep_default_for.rs
UTF-8
1,345
4.0625
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Example to demonstrate how to use the `keep_default_for` attribute. //! //! The generated `impl` blocks generate an item for each trait item by //! default. This means that default methods in traits are also implemented via //! the proxy type. Sometimes, this is not what you want. One special case is //! when the d...
true
190861aa178bb0a07d58f73064ab7ded3a38be6d
Rust
ChanTsune/Portable-Network-Archive
/lib/src/cipher/stream/write.rs
UTF-8
2,588
2.921875
3
[ "MIT" ]
permissive
use cipher::{ typenum::{IsLess, Le, NonZero, U256}, BlockSizeUser, KeyIvInit, StreamCipher, StreamCipherCoreWrapper, }; use std::io::{self, Write}; pub(crate) struct StreamCipherWriter<W, T> where W: Write, T: BlockSizeUser, T::BlockSize: IsLess<U256>, Le<T::BlockSize, U256>: NonZero, { w: ...
true
be0496edeafb5cdbbe4e6607064b9ee0a1de51b3
Rust
ThibautGeriz/rustipe
/src/domain/recipes/ports/dao.rs
UTF-8
1,061
2.609375
3
[]
no_license
use crate::domain::recipes::models::recipe::Recipe; use std::error::Error; #[derive(PartialEq, Debug)] pub struct NewRecipe<'a> { pub id: &'a str, pub user_id: &'a str, pub title: &'a str, pub description: Option<&'a str>, pub recipe_yield: Option<&'a str>, pub category: Option<&'a str>, pu...
true
46b73a7a9188383743752c9969aab838ebf4e8cf
Rust
themasch/rust-jvm
/src/java/runtime/mod.rs
UTF-8
20,731
2.96875
3
[]
no_license
use java::class_file::Method; use std::collections::HashMap; use java::class_file::ClassFile; use std::path::PathBuf; use std::sync::Arc; use java::class_file::ConstantType; use java::class_file::ValueType; use java::instructions::Instruction; /// these type of errors should not happen at all. /// Triggering one of ...
true
53e92b3ba893cb612a5c6b1d45febbc6dbfeab90
Rust
PM4Rs/promi
/src/stream/duplicator.rs
UTF-8
4,845
3.203125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Duplicate an event stream use crate::stream::plugin::{Declaration, Entry, Factory, FactoryType, PluginProvider}; use crate::stream::{AnyArtifact, ResOpt, Sink, Stream}; use crate::Result; /// Creates a copy of an extensible event stream on the fly /// /// A duplicator forwards a stream while copying each componen...
true
a1306f09bdc6fcdf3541a96cc08bda59f3f74f8d
Rust
ryanpbrewster/algorithmic-art
/src/bin/rgb-function.rs
UTF-8
1,278
3.453125
3
[ "MIT" ]
permissive
//! Make an RGB image based on the function Sin[x^2 + y^2] extern crate image; use std::fs::File; fn main() { let imgx = 800; let imgy = 800; let scalex = 2.0 / imgx as f32; let scaley = 2.0 / imgy as f32; // Create a new ImgBuf with width: imgx and height: imgy let mut imgbuf = image::Image...
true
f661a5493561dd13febf6b05a51dba8090df661c
Rust
Tsuyoshi-Iwanaga/learning_rust
/006/func6.rs
UTF-8
152
3.109375
3
[]
no_license
//クロージャ fn main() { let msg = String::from("Hello"); let n = 123; let func = move |x| { println!("{}/{}", msg, x); }; func(n); }
true
15da197ca9c93c2d8ceec7558f6ae06f078b1457
Rust
cloudevents/sdk-rust
/example-projects/axum-example/src/main.rs
UTF-8
3,170
2.78125
3
[ "Apache-2.0" ]
permissive
use axum::{ routing::{get, post}, Router, }; use cloudevents::Event; use http::StatusCode; use std::net::SocketAddr; use tower_http::trace::TraceLayer; fn echo_app() -> Router { Router::new() .route("/", get(|| async { "hello from cloudevents server" })) .route( "/", ...
true
5dcb36834bd214f033f23079de40cd76f9c3048e
Rust
konradsz/adventofcode2017
/day24/rust/bridge.rs
UTF-8
2,139
3.21875
3
[]
no_license
use std::fs; struct Bridge { strength: usize, length: usize, } fn build_bridge( bridges: &mut Vec<Bridge>, components: &Vec<(usize, usize)>, port: usize, strength: usize, length: usize, ) { bridges.push(Bridge { strength, length }); let connectors: Vec<usize> = components ....
true
252827f92452355622b0abb1a42df0e1a634d422
Rust
netpyoung/tinyrenderer-rs
/prj/src/base/color.rs
UTF-8
918
3.53125
4
[ "MIT" ]
permissive
#[derive(Clone, Copy)] pub struct Color { pub r: u8, pub g: u8, pub b: u8, } #[allow(dead_code)] pub const WHITE: Color = Color { r: 255, g: 255, b: 255, }; #[allow(dead_code)] pub const BLUE: Color = Color { r: 0, g: 0, b: 255, }; #[allow(dead_code)] pub const RED: Color = Color { ...
true
61486306306ec4f688053fc7af6505c352e80467
Rust
pbzweihander/async-h1
/tests/server_decode.rs
UTF-8
3,744
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
mod test_utils; mod server_decode { use super::test_utils::TestIO; use async_std::io::prelude::*; use http_types::headers::TRANSFER_ENCODING; use http_types::Request; use http_types::Result; use http_types::Url; use pretty_assertions::assert_eq; async fn decode_lines(lines: Vec<&str>) -...
true
54ba73ab1550d9d0c48c4567ecffd950bb124481
Rust
BafDyce/adventofcode
/2017/rust/day22/src/part2.rs
UTF-8
1,666
3.25
3
[ "Unlicense" ]
permissive
use super::*; enum State { Clean, Weakened, Infected, Flagged, } impl State { fn modify(&mut self) { *self = match self { State::Clean => { State::Weakened } State::Weakened => { State::Infected } S...
true
4eebf8135235e6d5146c1d1555e9b077e7a78653
Rust
RedBeardLab/circular-buffer-rs
/benches/fast_fill_vs_fill_by_hand.rs
UTF-8
957
2.671875
3
[]
no_license
use rbl_circular_buffer::*; fn main() { let mut buffer = CircularBuffer::new(10240); for i in 0..10240 { buffer.push(i); } let mut d = Vec::with_capacity(570); let mut t1 = buffer; let mut t = std::time::Duration::new(0, 0); for _ in 0..10_000 { let now = std::time::Insta...
true
5bbcb502328bc2ac1ddbc583d6c9dc1eda032a09
Rust
svartalf/rust-advent-of-code-2017
/src/bin/day03.rs
UTF-8
367
2.515625
3
[ "MIT" ]
permissive
extern crate aoc2017; use aoc2017::days::day03; fn main() { let input = aoc2017::read_trim("input/day03.txt").unwrap().parse::<usize>().unwrap(); let distance = day03::part1::distance(input); println!("Day 02 part 1 steps: {}", distance); let distance = day03::part2::search(input); println!("Day...
true
5cb6feaa893cc7956fd37e6b761c9dc3081b3c2c
Rust
rvanasa/funqy
/src/eval.rs
UTF-8
13,526
2.828125
3
[]
no_license
use error::*; use ast::*; use engine::*; use types::*; use eval_static::*; use std::fmt; use std::rc::Rc; use std::collections::HashMap; #[derive(Clone)] pub struct Macro(pub Ident, pub Rc<dyn Fn(&Exp, &Context) -> Ret<RunVal>>); impl fmt::Debug for Macro { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { w...
true
104254f63dc449c3345ab20b16506a907aa41b7a
Rust
solarnz/udmx
/src/main.rs
UTF-8
1,515
2.734375
3
[ "MIT" ]
permissive
extern crate libusb; extern crate rand; use std::process; use std::time::Duration; const UDMX_VENDORID: u16 = 0x16c0; const UDMX_PRODUCTID: u16 = 0x5dc; fn main() { let args: Vec<_> = std::env::args().collect(); let mut values: Vec<u8> = Vec::new(); if args.len() < 3 { println!("Usage: {binary}...
true
de88c4f8eb350705eca30925803b9aa25383fae7
Rust
BenjaminGuenin/rust-programming-tutorial
/src/main.rs
UTF-8
686
3.859375
4
[]
no_license
fn main() { let immutable_string = "hello"; // cannot be modified - stored on the stack let mut mutable_string = String::from("hello"); // can be modified - stored on the heap mutable_string.push_str(" world!"); println!("{}", mutable_string); // Scope ownership memory management { le...
true
13874b55dd26dfdaf4f654ec6816911384d55ede
Rust
hongweixiao/for_offer
/src/add_050.rs
UTF-8
386
3.328125
3
[]
no_license
fn add(n1: i32, n2: i32) -> i32 { let mut n1 = n1; let mut n2 = n2; while n2 !=0 { let t = n1 ^ n2; //不计算进位 n2 = (n1 & n2) << 1; // 进位 n1 = t; } n1 } #[cfg(test)] mod tests { use super::*; #[test] fn test_01() { assert_eq!(add(0, 3), 3); assert_eq!(add(1, 2), 3); assert_eq!(add(1...
true
af67c29ba99d923b65c1e111ca4c4cad516ac291
Rust
iximeow/jubilant-train
/src/bin/sigalrmy.rs
UTF-8
1,355
2.59375
3
[]
no_license
// This will either complete without error (overflowing the signal stack!!), or with a signal stack // guard page, crash with a segmentation fault. use std::mem; use std::ptr; use libc::{sigaction, sighandler_t, SA_ONSTACK, SA_SIGINFO, SIGSTKSZ}; use libc::{MAP_ANON, MAP_PRIVATE, PROT_READ, PROT_WRITE, SIGSEGV, SIGALR...
true
0f8ce855b32d27dacda7eb68849a91ed869290e7
Rust
josiah-language-learning/the-rust-language
/3chapter/variables-and-mutability/shadowing.rs
UTF-8
4,311
3.796875
4
[]
no_license
/* * Shadowing is not as dangerous as mutating because the shadowed variable * is limited to its scope. For example, changing a variable using 'mut' * in a fuction changes that variable's value everywhere in the program, * including outside that function's scope and all the way up the call * stack wherever that v...
true
1300248891dbd8a976799ef30851d26ba61bb834
Rust
WereDiggle/rust-raytracer
/src/geometry/ray.rs
UTF-8
3,113
3.171875
3
[ "MIT" ]
permissive
use super::*; #[derive(Debug, Clone, Copy)] pub struct Ray { pub origin: DVec3, pub direction: DVec3, depth: u32, contribution: Color, } impl Ray { pub const MIN_DISTANCE: f64 = 0.001; pub const MIN_CONTRIBUTION: f64 = 0.003; pub fn new(origin: DVec3, direction: DVec3, depth: u32) -> Ray {...
true
add40c8a5b16767700bea3f55c591818077c4bc6
Rust
ranjithsekar/rust
/rust-exp/src/loops.rs
UTF-8
376
3.40625
3
[]
no_license
pub fn run() { let mut count = 0; loop { count += 1; println!("loop: {}", count); if count == 5 { println!(" I am 5"); break; } } let mut num = 0; while num < 5 { num += 1; println!("while {}", num); } // For loop ...
true
ed615b907070691efd993bdf91698884c94541e6
Rust
gitter-badger/nameless
/nameless/src/pattern.rs
UTF-8
1,842
3.015625
3
[ "Apache-2.0" ]
permissive
use {Debruijn, Term}; pub trait Pattern: Term { type NamePerm; fn freshen(&mut self) -> Self::NamePerm; fn rename(&mut self, perm: &Self::NamePerm); fn on_free(&self, index: Debruijn, name: &Self::FreeName) -> Option<Self::BoundName>; fn on_bound(&self, index: Debruijn, name: &Self::BoundName) -> ...
true
01affe88591a2e3969fd08a3903ea3806abfdc91
Rust
jfoote/wasmtime
/crates/wasi-common/yanix/src/socket.rs
UTF-8
844
2.53125
3
[ "LLVM-exception", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
use crate::{Errno, Result}; use std::os::unix::prelude::*; #[derive(Debug, Clone, Copy)] #[repr(i32)] pub enum SockType { Stream = libc::SOCK_STREAM, Datagram = libc::SOCK_DGRAM, SeqPacket = libc::SOCK_SEQPACKET, Raw = libc::SOCK_RAW, Rdm = libc::SOCK_RDM, } pub unsafe fn get_socket_type(fd: RawFd...
true
332cd9b1c31cd46bafe7cf20f711ff6593b76fc2
Rust
Samoxive/SafetyJim
/src/database/warns.rs
UTF-8
2,717
2.65625
3
[ "MIT" ]
permissive
use std::sync::Arc; use sqlx::{Error, PgPool, Row}; #[derive(sqlx::FromRow)] pub struct Warn { pub id: i32, pub user_id: i64, pub moderator_user_id: i64, pub guild_id: i64, pub warn_time: i64, pub reason: String, pub pardoned: bool, } pub struct WarnsRepository(pub Arc<PgPool>); impl War...
true
ced7378c57bdff6834045238e305824442dcf101
Rust
tokio-rs/tracing
/tracing/test-log-support/src/lib.rs
UTF-8
2,261
3.109375
3
[ "MIT" ]
permissive
use log::{LevelFilter, Log, Metadata, Record}; use std::sync::{Arc, Mutex}; pub struct Test { state: Arc<State>, } struct State { last_log: Mutex<Option<String>>, } struct Logger { filters: Vec<(&'static str, LevelFilter)>, state: Arc<State>, } impl Log for Logger { fn enabled(&self, meta: &Meta...
true
a0ef54357f4c6ce2b739d8126add3c9b73e364f7
Rust
tectonic-typesetting/tectonic
/tests/formats.rs
UTF-8
5,722
2.578125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2017-2022 the Tectonic Project // Licensed under the MIT License. /// Test that we can operate in "initex" mode to generate format files as /// expected. Unlike TeX we set things up so that formats should be /// byte-for-byte reproducible given the same inputs. Since formats are big, /// we check for equa...
true
213f5c1f81d7bde3ab40361730877ff3c5782820
Rust
bridger-herman/scriptable-game
/src/transform.rs
UTF-8
518
2.890625
3
[]
no_license
// transform.rs // // Copyright (c) 2019, Univerisity of Minnesota // // Author: Bridger Herman (herma582@umn.edu) //! Transformation matrix for 3-space, stored in a 4x4 matrix #[derive(Debug, Serialize, Deserialize)] pub struct Transform { pub matrix: [f32; 16], } impl Transform { pub fn identity() -> Self ...
true
25f25d5e240ca76ff05b35e01b4cc86aaa754fcc
Rust
apjaffe/aoc2019
/src/bin/day6-2.rs
UTF-8
1,007
3.0625
3
[]
no_license
use std::io::{self, BufRead}; use std::collections::HashMap; fn downstream(orbits:&HashMap<String,String>, query:&str) -> HashMap<String, i64> { let mut current = query; let mut res = HashMap::new(); let mut dist = 0; while let Some(next) = orbits.get(current) { res.insert(next.to_string(), dis...
true
cf921908bb4a927e927085229d6cc9782e9da4b8
Rust
rust-lang/glacier
/fixed/63355.rs
UTF-8
608
2.71875
3
[ "Apache-2.0", "MIT" ]
permissive
#![feature(type_alias_impl_trait)] pub trait Foo {} pub trait Bar { type Foo: Foo; fn foo() -> Self::Foo; } pub trait Baz { type Foo: Foo; type Bar: Bar<Foo = Self::Foo>; fn foo() -> Self::Foo; fn bar() -> Self::Bar; } impl Foo for () {} impl Bar for () { type Foo = FooImpl; fn f...
true
7d256e48345ce63ca8e4b7bfb9cd0d1b6e8b0d02
Rust
afidegnum/VRME-Server-Rust
/vrme_server/src/meetings/get_session_info.rs
UTF-8
1,615
2.84375
3
[ "MIT" ]
permissive
//! Handler for getting meeting session information. use actix_web::web; use actix_web::{Error, HttpResponse}; use deadpool_postgres::Client; use serde::{Deserialize, Serialize}; use uuid::Uuid; use crate::database::postgresql::PersistentConnectionPool; use crate::service_errors::ServiceError; #[derive(Debug, Deseri...
true
c68fa50bc1b11e138af6f8f6146cd1a915e8d420
Rust
oxidecomputer/third-party-api-clients
/github/src/http_cache.rs
UTF-8
6,788
2.9375
3
[ "MIT", "LicenseRef-scancode-unknown" ]
permissive
//! Implements <https://tools.ietf.org/html/rfc7232> Conditional Requests. use std::{ collections::hash_map::DefaultHasher, ffi::OsStr, fmt::Debug, fs, hash::{Hash, Hasher}, io, path::{Path, PathBuf}, }; use crate::ClientError; use crate::ClientResult; use http::Uri; /// A type for an HTTP...
true
9e9ef856718982d3acf74dd06679b882fc400921
Rust
BafDyce/adventofcode
/2015/rust/01/part1.rs
UTF-8
922
3.46875
3
[ "Unlicense" ]
permissive
// adventofcode - day 1 // part 1 use std::io::prelude::*; use std::fs::File; fn main() { let directions = import_data(); let mut floor = 0i32; // we iterate over every character and increment/decrement whenever we hit // a ( or ), respectively. // any other character will just be ignored fo...
true
a0ff0bb854f03c0751de0eb8fa8b30af00a35ae8
Rust
SMotaal/experimental-wasmtime
/tests/custom_signal_handler.rs
UTF-8
10,956
2.71875
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
#[cfg(not(target_os = "windows"))] mod tests { use core::cell::Ref; use std::rc::Rc; use std::sync::atomic::{AtomicBool, Ordering}; use wasmtime::*; use wasmtime_interface_types::{ModuleData, Value}; fn invoke_export( instance: &HostRef<Instance>, data: &[u8], func_name:...
true
ed08b1480ffe6d6864d51f17780607cb67d8760b
Rust
stijnh/rust-advent-of-code-2020
/src/day15.rs
UTF-8
1,204
3.25
3
[]
no_license
use crate::common::*; use std::mem::replace; fn parse_input(line: &str) -> Result<Vec<usize>> { line.split(',').map(|s| Ok(s.parse()?)).collect() } fn play_for_n_rounds(n: usize, nums: &[usize]) -> usize { if n < nums.len() { return nums[n]; } let m = max(nums).unwrap(); let mut spoken = ...
true
eb320908732f4c12095ec3cf994e524631a6d1e6
Rust
bpglaser/advent
/2022/day07_part02/src/main.rs
UTF-8
4,499
3.234375
3
[]
no_license
use std::{cell::Cell, cmp, collections::HashMap, env::args, fs::read_to_string}; use FileSystem::*; use Token::*; const TOTAL_FS_SIZE: usize = 70_000_000; const TARGET_UNUSED: usize = 30_000_000; #[derive(Debug, PartialEq)] enum Token<'a> { CD(&'a str), LS, DirEntry(&'a str), FileEntry(usize, &'a str...
true
ce9b697792be38d68958d179d69e025d24102516
Rust
pbzweihander/rust-dependency-injection-proof-of-concept
/examples/example.rs
UTF-8
2,122
2.90625
3
[]
no_license
use std::sync::Arc; use dipoc::boxed::BoxFuture; use dipoc::{HasProvider, Provider}; type Error = String; trait Context: 'static {} trait Repository { type Context: Context; fn get(&self, ctx: &mut Self::Context) -> usize; } trait Service { fn serve(&mut self) -> usize; } struct ContextImpl; impl Con...
true
8f75217ccb87eeee42177dd1a46d20f3bbbbe92a
Rust
hiroaqii/rust-99-problems
/p15/src/lib.rs
UTF-8
598
3.890625
4
[]
no_license
/// Replicate the elements of a list a given number of times. fn repli<T: Copy>(vec: &Vec<T>, n: usize) -> Vec<T> { let mut ret: Vec<T> = Vec::with_capacity(vec.len() * n); for v in vec { for _ in 1..=n { ret.push(*v); } } ret } #[cfg(test)] mod tests { use super::*; ...
true
82bf869bc8f0b3943373ca3b3ec07ba12391c59c
Rust
MPThLee/aqicn-rs
/src/query.rs
UTF-8
616
2.640625
3
[]
no_license
use serde_json; #[derive(Deserialize, Debug)] pub struct Queries { status: String, pub data: Vec<Query> } #[derive(Deserialize, Debug)] pub struct Query { pub lat: f64, pub lon: f64, pub uid: i32, pub aqi: String } impl Queries { pub fn query(token: &str, latlng: &str) -> Queries { ...
true
c55f18d699f04b896c3b5c837fdbc4207213aa08
Rust
myoKun345/filite
/src/routes.rs
UTF-8
16,151
2.578125
3
[ "MIT" ]
permissive
//! Actix route handlers use crate::setup::{self, Config}; use actix_identity::Identity; use actix_web::{error::BlockingError, web, HttpRequest, HttpResponse, Responder}; use base64; use chrono::{DateTime, NaiveDateTime, Utc}; use diesel; use serde::Serialize; #[cfg(feature = "dev")] use crate::get_env; #[cfg(feature...
true
ed57f22232ded88c6c122a61803804a423763bbb
Rust
EmbarkStudios/tame-oauth
/examples/default_creds.rs
UTF-8
3,189
2.96875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use tame_oauth::gcp::*; // This example shows the basics for creating a token provider for the default // credentials on the system. If you want to use a service account, set // `GOOGLE_APPLICATION_CREDENTIALS` to a service account key path, if have // gcloud installed, you can just run this as is and it will work as ...
true
b7f9dd1e1bf3198a50285edc983583a19892870e
Rust
gobanos/cargo-aoc
/cargo-aoc/src/project.rs
UTF-8
1,227
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
use aoc_runner_internal::DayParts; use std::error; use std::fs; use std::process; pub struct ProjectManager { pub name: String, pub slug: String, } impl ProjectManager { pub fn new() -> Result<ProjectManager, Box<dyn error::Error>> { let cargo: toml::Value = fs::read_to_string("Cargo.toml")?.parse...
true
baa0b91e6f42315bef8a26c55053c4a28d525efb
Rust
aethelwyrd/GreasyFriedChicken
/rust_thread/src/thread_simple.rs
UTF-8
898
3.59375
4
[ "MIT" ]
permissive
//thread_simple.rs //Copyright 2015 David Huddle use std::thread; /// Spawns num_threads threads. Each thread counts to work_items on the console /// /// # Examples /// //Spawns five threads that each count to 10 /// /// do_thread(5,10); pub fn do_thread(num_threads:i32, work_items: i32){ let nums = 1..num_thre...
true
59d29efc40d3549fd43f242791d26fe29ad2de84
Rust
anachrome/rust-readline
/examples/callback-example.rs
UTF-8
733
3.0625
3
[ "MIT" ]
permissive
extern crate readline; use std::process::exit; fn eval(line: Option<String>) { let line = match line { Some(line) => line, None => { println!(""); exit(0); } }; if line == "quit" { exit(0); } // add words that start with 'a' to the history ...
true
60fb9860c1448c8c0a1420a2559a0de24c28fb18
Rust
jroimartin/expos
/uefi/src/acpi.rs
UTF-8
10,163
2.984375
3
[]
no_license
//! This module provides access to ACPI. use core::convert::TryInto; use crate::utils; use crate::{Error, Ptr}; /// Signature of the RSDP structure. const ACPI_RSDP_SIGNATURE: &[u8] = b"RSD PTR "; /// Size of the SDT header. const ACPI_SDT_SIZE: usize = core::mem::size_of::<AcpiSdtHeader>(); /// Root System Descri...
true
917667930273a3fdd48602dfb7bb50f8b403034f
Rust
leftiness/lingo
/src/xdg/xdg.rs
UTF-8
1,099
3.140625
3
[ "MIT" ]
permissive
use std::fmt::Display; /// Supported XDG base directory types #[derive(Debug)] pub enum Xdg { Config, Cache, } impl Xdg { /// XDG environment variable pub fn env(&self) -> Option<&'static str> { match *self { Xdg::Config => option_env!("XDG_CONFIG_HOME"), Xdg::Cache => option_env!("XDG_CACHE_...
true
4786f7c097f7dfd5a36aa961db8b9b5327e96a0c
Rust
Anxys/rusty-weather
/src/main.rs
UTF-8
1,637
3.140625
3
[ "MIT" ]
permissive
extern crate hyper; extern crate regex; extern crate clap; use std::io::Read; use hyper::Client; use hyper::header::Connection; use regex::Regex; use clap::{Arg,App}; fn main() { // Setup CLI let matches = App::new("Accuweather") .version("1.0") .author("James B. <j-bartholomew@live.com>") ...
true
eb7a0dc8cce15dd5fd6e90e1cbf4233057ead9c8
Rust
GiGainfosystems/diesel-oci
/src/oracle/query_builder/alias.rs
UTF-8
1,864
2.59375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::Oracle; use diesel::query_builder::{AstPass, QueryFragment, QueryId}; use diesel::result::QueryResult; /// Create an alias for a given expression /// /// This is a helper to provide aliasing support while it's not in diesel itself /// It probably needs improvements before something like this can be merged ...
true
79da45b286db8995404edfd32429376715027399
Rust
afnanenayet/nib
/src/material/diffuse.rs
UTF-8
1,022
2.859375
3
[ "MIT" ]
permissive
use crate::{ hittable::HitRecord, material::{BSDFRecord, BSDF}, ray::Ray, sampler::{primitives::sample_unit_sphere, Sampler}, types::Float, }; use cgmath::Vector3; use serde::{Deserialize, Serialize}; /// A diffuse BSDF function /// /// This BSDF models a typical matte, or non-glossy surface. The u...
true
70f8aad54557b9287bc62c4198fbf215f3211aa5
Rust
matter-labs/zksync
/core/lib/crypto/src/convert.rs
UTF-8
3,322
3.25
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ error::ConversionError, franklin_crypto::bellman::pairing::ff::{PrimeField, PrimeFieldRepr}, }; /// Extension trait denoting common conversion method for field elements. pub trait FeConvert: PrimeField { /// Converts the field element into a byte array. fn to_bytes(&self) -> Vec<u8> { ...
true
df69d57fef3fdb986fb935e22a6b1b8bf2381a80
Rust
shybyte/chord-detection-rust
/examples/visualize-wave.rs
UTF-8
2,736
2.59375
3
[ "MIT" ]
permissive
extern crate sdl2; use sdl2::render::Canvas; use sdl2::pixels::Color; use sdl2::event::Event; use sdl2::keyboard::Keycode; use std::time::Duration; use sdl2::rect::Point; use sdl2::audio::{AudioCallback, AudioSpecDesired}; use std::sync::mpsc; use std::i16::MAX as I16_MAX; struct Recording { new_frame_sender: mp...
true
47a9021d00dcd1797d7a8dedabfce2751a59eab3
Rust
luojia65/cc2640r2f
/src/ssi1/ris.rs
UTF-8
10,179
2.859375
3
[ "WTFPL" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::RIS { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W...
true
2ef72f82a8a1dd9fc62f187c66649adfb57dff31
Rust
rdelfin/irc_tweeter
/src/tweeter.rs
UTF-8
1,063
2.828125
3
[ "MIT" ]
permissive
use crate::config::Settings; use egg_mode::error::Result; use egg_mode::tweet::DraftTweet; use egg_mode::{KeyPair, Token}; pub struct Tweeter { token: Token, write: bool, } impl Tweeter { pub fn new(settings: &Settings) -> Tweeter { let key = KeyPair::new( settings.twitter.api_key.clon...
true
38fafc3191ef12a1d57aba7eeeccf0fd72ba1263
Rust
belanger-simon/Advent-of-Code-2020
/day10/src/main.rs
UTF-8
1,176
3.21875
3
[]
no_license
use std::io; use std::io::prelude::*; fn main() { let mut input : Vec<u32> = io::stdin().lock().lines() .map(|l| l.unwrap()) .take_while(|l| l != "") .map(|l| l.parse::<u32>().unwrap()) .collect(); input.push(0); input.so...
true
3ff30c8ad91aa29f46bf926fd92b10f20823fa6f
Rust
sophiecollard/recipe-app
/src/recipe.rs
UTF-8
410
2.625
3
[]
no_license
#[path = "quantity.rs"] mod quantity; use crate::ingredient::Ingredient; use quantity::Quantity; pub struct Recipe { id: u32, name: String, ingredients: Vec<(Ingredient, Quantity)>, } impl Recipe { fn new(id: u32, name: &str, ingredients: Vec<(Ingredient, Quantity)>) -> Self { Recipe { ...
true
102422f159122ede2df27334be906a5898cc3c7b
Rust
clarkenheim/pacific-raft-3
/src/player.rs
UTF-8
887
3.453125
3
[]
no_license
const DEFAULT_ENERGY:u8 = 100; const DEFAULT_HUNGER:u8 = 0; const DEFAULT_HYGIENE:u8 = 100; // todo - illness ( vec of illness types ) // Health is a crude indicator of general health #[derive (Debug, PartialEq)] pub enum Health { Perfect, Great, Ok, Poor, Critical } pub struct Player{ energy:...
true
d9b8a9f59a347aa668c36c0cc77b15543ae13050
Rust
aytdm/study
/017_hello_rust/variables/src/main.rs
UTF-8
1,645
3.921875
4
[]
no_license
use std::io; fn main() { let mut x = 5; println!("The value of x is: {}", x); x = 6; println!("The value of x is: {}", x); let guess: u32 = "42".parse().expect("Not a number!"); println!("{}", guess); // addition let _sum = 5 + 10; // subtraction let _difference = 95.5 - 4.3...
true
7c0e427b6b565bf24fda29b71ad57969ced2e9e6
Rust
trexert/advent_of_code_2020
/aoc/src/bin/day15/main.rs
UTF-8
1,028
3.3125
3
[]
no_license
use std::collections::HashMap; enum Part { One, Two, } fn main() { let starting_numbers = include_str!("input.txt") .split(",") .map(|s| s.parse().unwrap()) .collect(); println!("part1: {}", solve(&starting_numbers, Part::One)); println!("part2: {}", solve(&starting_numbers...
true
b86eb92497f857da99d11d80d013e7915852609f
Rust
alvinmatias69/simple-github-bot
/index.rs
UTF-8
1,395
2.75
3
[]
no_license
use http::{self, Request, Response}; use reqwest::{header, Client}; use serde_json; use serde_json::{json, Value}; use std::env; use url::Url; fn handler(request: Request<String>) -> http::Result<Response<String>> { let method = request.method(); if method.as_str() == "POST" { let body: String = reque...
true
45254cdb7e6f103bd7ad9ac4593561e0d1b127e5
Rust
ys-kalyakin/leetcode
/rust/src/reverse_integer/mod.rs
UTF-8
773
3.6875
4
[ "MIT" ]
permissive
/// https://leetcode.com/problems/reverse-integer/ #[allow(dead_code)] pub fn reverse(x: i32) -> i32 { let mut value = x; let mut reversed = 0; while value != 0 { let pop = value % 10; value /= 10; if reversed > i32::MAX / 10 || (reversed == i32::MAX / 10 && pop > 7) { ...
true
16b1038f69169a8e0350e9bc8776a6151f4a9547
Rust
vulkano-rs/vulkano
/vulkano/src/memory/allocator/suballocator.rs
UTF-8
116,108
2.59375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) 2016 The vulkano developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, // at your option. All files in the project carrying such // notice may not be ...
true
d7575b5acfce83683b5dfcb998b5bac5f6617ff1
Rust
t0ggah/raytracer
/src/vector/mod.rs
UTF-8
745
3.140625
3
[]
no_license
mod color; mod vec3; pub use color::Color; pub use vec3::Vec3; pub fn unit_vector(v: Vec3) -> Vec3 { v / v.length() } pub fn dot(u: &Vec3, v: &Vec3) -> f32 { u.x() * v.x() + u.y() * v.y() + u.z() * v.z() } pub fn reflect(v: Vec3, n: Vec3) -> Vec3 { v - n * 2.0 * dot(&v, &n) } pub fn refract(uv: Vec3, n...
true
7e5b52077d4876b822287f4e4151c51be9cd7e91
Rust
webern/rs
/xtest/src/xml_file.rs
UTF-8
880
2.953125
3
[ "MIT" ]
permissive
use std::fs::read_to_string; use std::path::PathBuf; use crate::Metadata; /// Represents a test file including paths to the test file and its metadata file. #[derive(Debug, Clone)] pub struct XmlFile { pub name: String, pub xml_path: PathBuf, pub metadata: Metadata, pub metadata_path: PathBuf, } impl...
true
45a6fd4ca11ecc026dd86e9729b4da867f4fa4af
Rust
imbaczek/rust-lightsout
/src/lightsout.rs
UTF-8
5,108
3.25
3
[ "ISC" ]
permissive
pub trait Level { fn size(&self) -> (usize, usize); fn is_solved(&self) -> bool; fn make_move<'a>(&'a mut self, x: usize, y: usize) -> &'a mut dyn Level; fn get(&self, x: usize, y: usize) -> Option<usize>; fn set(&mut self, x: usize, y: usize, v: usize) -> bool; } #[derive(Debug)] pub struct Struct...
true
56041fc9d3d2c6c963d3dc40f459ccd212f552d4
Rust
abargiela/xaynet
/rust/xaynet-server/src/state_machine/phases/idle.rs
UTF-8
7,006
2.578125
3
[ "Apache-2.0" ]
permissive
use xaynet_core::{ common::RoundSeed, crypto::{ByteObject, EncryptKeyPair, SigningKeySeed}, }; use crate::state_machine::{ events::{DictionaryUpdate, MaskLengthUpdate}, phases::{Phase, PhaseName, PhaseState, Shared, Sum}, PhaseStateError, StateMachine, }; #[cfg(feature = "metrics")] use crate:...
true
ee29ad2bbfa48e6bd5528db1c4f1e5ef7a106e08
Rust
futurepaul/font-kit
/src/sources/fontconfig.rs
UTF-8
13,104
2.578125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
// font-kit/src/sources/fontconfig.rs // // Copyright © 2018 The Pathfinder Project Developers. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file m...
true
65a16d056c1c27fd31536b3795dba5b75312e694
Rust
rust-lang/crates.io
/src/middleware/app.rs
UTF-8
746
2.984375
3
[ "MIT", "Apache-2.0" ]
permissive
use axum::middleware::Next; use axum::response::Response; use http::Request; use crate::app::AppState; use crate::controllers::util::RequestPartsExt; /// `axum` middleware that injects the `AppState` instance into the `Request` extensions. pub async fn add_app_state_extension<B>( app_state: AppState, mut requ...
true
bc1feff545bfb7a875d652dab5921dcc5d2bda02
Rust
prz23/zinc
/zinc-syntax/src/tree/expression/tree/builder.rs
UTF-8
8,702
3.34375
3
[ "Apache-2.0" ]
permissive
//! //! The expression tree builder. //! use zinc_lexical::Location; use crate::tree::expression::tree::node::operand::Operand as ExpressionOperand; use crate::tree::expression::tree::node::operator::Operator as ExpressionOperator; use crate::tree::expression::tree::node::Node as ExpressionTreeNode; use crate::tree::...
true
f18b1d057bd3e356f19b0c532a4dacf933fadc96
Rust
novemberisms/RustyBird
/src/score_drawer.rs
UTF-8
1,076
2.59375
3
[]
no_license
use SCREENWIDTH; // use SCREENHEIGHT; use opengl_graphics::GlGraphics; use piston::input::RenderArgs; use graphics::Context; use assets::Sprite; use assets::AssetManager; pub struct ScoreDrawer<'a> { digit_sprites: [Sprite<'a>; 10], } impl<'a> ScoreDrawer<'a> { pub fn new(assets: &'a AssetManager) -> S...
true
d8203aa5381d2e174454b94fcbd9ff1840a1b2a4
Rust
maenzhier/rustling-ontology
/src/parser.rs
UTF-8
4,157
2.71875
3
[ "Apache-2.0" ]
permissive
use rustling_ontology_values::dimension::*; use rustling; #[derive(Debug, Hash, Clone, Eq, PartialEq,Serialize,Deserialize)] pub enum Feat { Rules(Vec<rustling::Sym>), Grains(Vec<usize>), } impl rustling::Feature for Feat {} pub struct FeatureExtractor(); impl rustling::FeatureExtractor<Dimension, Feat> for Fea...
true
07e4b485cdfbf6b90295d4eea16454b1b255ae56
Rust
patocallaghan/adventofcode
/2020/day3/rs/src/main.rs
UTF-8
1,759
3.5625
4
[]
no_license
use std::fs; fn main() { let contents = fs::read_to_string("../input.txt").expect("Something went wrong reading the file"); // let contents = "..##....... // #...#...#.. // .#....#..#. // ..#.#...#.# // .#...##..#. // ..#.##..... // .#.#.#....# // .#........# // #.##...
true
dc6f72e8905dea40be9adfc593b74a1f0ab7b1a1
Rust
rbalicki2/hello-rocket
/src/models/authenticated_user.rs
UTF-8
1,862
2.71875
3
[]
no_license
use rocket::request::{FromRequest,Request,Outcome}; use rocket::outcome::Outcome::{Success,Failure}; use rocket::http::{HeaderMap,Status}; use diesel::result::QueryResult; use diesel::prelude::*; use app::db; use models::OauthToken; use app::schema::users; use models::User; use models::UserRole; #[derive(Debug)] pub ...
true
26c2e53934c3eaef08bfca49ceee82fd3e494436
Rust
schultetwin1/pfctl-rs
/src/rule/icmp.rs
UTF-8
3,137
2.671875
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright 2021 Mullvad VPN AB. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according...
true
fcc53440e66eebb45a591f620d5f14f4c3b5cb58
Rust
ytyaru/Rust.Error.20190626114831
/src/4/main.rs
UTF-8
564
2.90625
3
[ "CC0-1.0" ]
permissive
/* * Rustで例外処理。 * CreatedAt: 2019-06-26 */ use std::fs::File; use std::io::ErrorKind; fn main() { let f = File::open("hello.txt"); let f = match f { Ok(file) => file, Err(ref error) if error.kind() == ErrorKind::NotFound => { match File::create("hello.txt") { Ok(f...
true
b68a39713c2890712c7929f7f9ce498e53c3cf00
Rust
Atul9/assert2-rs
/src/lib.rs
UTF-8
5,430
3.515625
4
[ "BSD-2-Clause" ]
permissive
#![feature(specialization)] //! All-purpose [`assert!(...)`](macro.assert.html) and [`check!(...)`](macro.check.html) macros, inspired by [Catch2](https://github.com/catchorg/Catch2). //! //! This crate is currently a work in progress. //! It relies on a nightly compiler with the `proc_macro_span` and `specialization`...
true
c610a2e3c7b2b9f7911839c9c39fda79ad4eee28
Rust
sisshiki1969/cilk
/src/ir/merge_ret.rs
UTF-8
2,602
2.71875
3
[ "MIT" ]
permissive
use crate::ir::{ builder::{Builder, FuncRef, FunctionEntity}, function::Function, module::Module, opcode::Opcode, types::Type, value::Value, }; pub struct MergeReturns {} struct MergeReturnsOnFunction<'a> { func: &'a mut Function, } impl MergeReturns { pub fn new() -> Self { S...
true
507b40193b7f0019ca5a6fd00844c7727afd8e81
Rust
kette-language/drip-old
/crates/drip_parser/src/grammar/structs.rs
UTF-8
1,786
2.703125
3
[]
no_license
use crate::grammar::decl; use crate::grammar::types; use crate::parser::Parser; use drip_lexer::TokenKind; use drip_syntax::SyntaxKind; pub(crate) fn struct_def(p: &mut Parser) { assert!(p.at(TokenKind::StructKw)); p.bump(); struct_field_list_def(p); } fn struct_field_list_def(p: &mut Parser) { assert...
true
7b761cdfae2cdf1c6d2c3e17c48dee05542f9ffb
Rust
DylanFrancis/RustConwaysGameOfLife
/src/systems/rules/reproduction.rs
UTF-8
1,806
2.578125
3
[]
no_license
use specs::{System, Join, ReadStorage, Write}; use specs::shred::DynamicSystemData; use std::collections::{HashMap, HashSet}; use crate::components::{LiveCell, Position, DeadCell}; use crate::systems::rules::utils; use crate::resources::next_iteration::NextIteration; use crate::systems::rules::rule::Rule; pub struct R...
true
8384e5d3ccdfa70c665caddec4b42685aa0b4b94
Rust
say3no/try_rust
/tour/src/chapter6_text/tour67_string.rs
UTF-8
746
3.5
4
[]
no_license
/* A String is as struct that wons a sequence of utf-8 bytes in heap meoary. Because sits memory is on the heap, it can be extended, modified, etc. in ways string literals cannnot. Common methods: * push_str to add more uf08 bytes to the end of string * replace to replace sequence of utf-8 bytes with others * to_lowe...
true
727421374f3fe9d1c6988326200992582ae0a75d
Rust
jaketarnow/cryptopals
/src/main.rs
UTF-8
1,633
3.53125
4
[]
no_license
extern crate rustc_serialize; use rustc_serialize::hex::FromHex; use rustc_serialize::base64::{ToBase64, STANDARD}; #[derive(Debug)] pub enum LogicError { InvalidLengthCheck, } fn xor(data: &[u8], other_data: &[u8]) -> Result<Vec<u8>, LogicError> { if data.into_iter().len() != other_data.into_iter().len() { Err(L...
true
66c266bd035093cb874b24c1a593f0367e1336fc
Rust
geofmureithi-zz/rabble
/src/service/connection_handler.rs
UTF-8
832
2.765625
3
[ "Apache-2.0" ]
permissive
use envelope::Envelope; use correlation_id::CorrelationId; use pid::Pid; /// Implement this for a specific connection handler pub trait ConnectionHandler: Sized { type Msg; type ClientMsg; fn new(pid: Pid, id: u64) -> Self; fn handle_envelope(&mut self, Envelope<Self::Msg>, &mut Vec<ConnectionMsg<Self...
true
00827d8b75573ed9ebe4b4d87d6ec64740a960e5
Rust
mb64/mish
/src/funcs/o.rs
UTF-8
620
3.421875
3
[ "MIT" ]
permissive
use Flt; pub fn abs<T: Flt>(f: T) -> T { if f < T::ZERO { -f } else { f } } pub fn floor<T: Flt>(f: T) -> T { f - abs(f % T::ONE) } pub fn ceil<T: Flt>(f: T) -> T { floor(f) + T::ONE } pub fn trunc<T: Flt>(f: T) -> T { if f < T::ZERO { ceil(f) } else { flo...
true
335cfa1cbad2cb4866e14adf6966641a9cc7e9df
Rust
Rukenshia/dutrack-rs
/lib/src/stamp/mod.rs
UTF-8
2,079
2.921875
3
[]
no_license
use db::Database; use uuid::Uuid; use log::LOGGER; use db::models::*; use db::schema::stamps; use diesel::prelude::*; use diesel; use chrono::NaiveDateTime; use chrono::prelude::UTC; #[derive(Serialize)] pub struct PublicStamp { pub id: String, pub fence: String, pub event: String, pub time: NaiveD...
true
87f200cbc9a72172c25393fb956b53cf73f96b75
Rust
DrkSephy/rust-sandbox
/src/ifelse.rs
UTF-8
902
4.03125
4
[]
no_license
/* * Branching using if/else is similar to C, but no () needed. Due to Rust * type safety, all the branches must return the same type. */ fn main(){ let n = 5i; if n < 0 { print!("{} is negative", n); } else if n > 0 { print!("{} is positive", n); } else { print!("{} is zero"...
true
9685985b0a861dbd9148c3258b9e14a21fa3627a
Rust
valentinpy/k64
/src/mcg/c5.rs
UTF-8
23,683
2.609375
3
[ "MIT" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u8, } #[doc = r" Value to write to the register"] pub struct W { bits: u8, } impl super::C5 { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W) -...
true
7f0adb0f68eb8731ae4ce289fabafae9ff86bd8e
Rust
anthony-c-martin/aoc2017
/src/challenges/challenge_7.rs
UTF-8
7,488
3.15625
3
[]
no_license
use std::str; use std::iter; use std::collections::HashSet; use std::collections::HashMap; pub fn execute(input: &str) { let result_a = challenge_a(input); println!("Challenge 7a: {}", result_a); let result_b = challenge_b(input); println!("Challenge 7b: {}", result_b); } fn challenge_a(input: &str) -...
true