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
44520c98fe1bf5b558f73341c605007baba6bb40
Rust
Velfi/plotlings
/src/lib/mod.rs
UTF-8
2,725
2.90625
3
[]
no_license
pub mod interval; pub mod svg; use std::ops::{Add, Div, Mul, Range, Sub}; pub fn get_wrapping_index(x: isize, y: isize, width: usize, height: usize) -> usize { let (width, height) = (width as isize, height as isize); (((y + height) % height) * width + ((x + width) % width)) as usize } pub fn map_t_of_range_a...
true
b2e86fbf2da1422a4ee0e5bf183c793006253bf6
Rust
aatxe/oxide-test-suite
/nll/maybe-initialized-drop.rs
UTF-8
436
2.515625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//compile-flags: -Zborrowck=mir #![allow(warnings)] struct Wrap<'p> { p: &'p mut i32 } fn drop_wrap<'a, 'b>(wrap: &'a mut Wrap<'b>) where 'b: 'a { *(*wrap).p += 1; } fn main() { let mut x = 0; let tmp0: &'t0 mut i32 = &mut x; let wrap = Wrap::<'t0> { p: tmp0 }; x = 1; //~ ERROR cannot assign to ...
true
dca5215baa9bbdbb31d805ec06b1ba12a02caa2c
Rust
Mebus/nalgebra
/src/geometry/isometry_alias.rs
UTF-8
958
2.59375
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
use crate::base::dimension::{U2, U3}; use crate::geometry::{Isometry, Rotation2, Rotation3, UnitComplex, UnitQuaternion}; /// A 2-dimensional direct isometry using a unit complex number for its rotational part. Also known as a rigid-body motion, or as an element of SE(2). pub type Isometry2<N> = Isometry<N, U2, UnitC...
true
7cd068153e0016037d07f6f4e90fa4626a840265
Rust
sidvishnoi/leetcode-rust
/1035-uncrossed-lines.rs
UTF-8
879
3.234375
3
[]
no_license
struct Solution; impl Solution { pub fn max_uncrossed_lines(a: Vec<i32>, b: Vec<i32>) -> i32 { let mut dp = vec![vec![0; b.len() + 1]; a.len() + 1]; for i in 1..=a.len() { for j in 1..=b.len() { if a[i - 1] == b[j - 1] { dp[i][j] = 1 + dp[i - 1][j - 1...
true
1fe26a22eeae2a9b7dc15091f3bad100120f2c2c
Rust
Sabientje65/Rusty_new
/Main/src/main.rs
UTF-8
2,671
3.65625
4
[]
no_license
mod enum_test; use enum_test::{enum_test}; // use std::net::{IpAddr}; #[derive(Debug)] struct Rectangle { width: u32, height: u32 } enum IpAddress { V4(u8, u8, u8, u8), V6(String) } impl Rectangle { fn calculate_area(&self) -> u32{ // self = Rectangle { // width: self.width...
true
bfd1a3b7293ccf60b3bb4ce59004b8bc4f4623f4
Rust
mingwandroid/dustr
/dustr/src/types/result.rs
UTF-8
1,077
2.578125
3
[]
no_license
use crate::helpers::*; use ::syn::*; /// The std lib's `Result` type behavior. pub struct Behavior; impl super::Behavior for Behavior { fn is(&self, sty: &Type) -> bool { if let Type::Path(tp) = sty { is_same_id(&tp.path, "Result") } else { false } } fn impo...
true
83a0ad76a623095f03816b62918b6ce80a99e0e7
Rust
gramlang/gram
/src/tokenizer.rs
UTF-8
30,593
2.890625
3
[ "MIT" ]
permissive
use { crate::{ error::{listing, throw, Error, SourceRange}, format::CodeStr, token::{ TerminatorType, Token, Variant, BOOLEAN_KEYWORD, ELSE_KEYWORD, FALSE_KEYWORD, IF_KEYWORD, INTEGER_KEYWORD, THEN_KEYWORD, TRUE_KEYWORD, TYPE_KEYWORD, }, }, num_bigint:...
true
e7ae0ee4a0632c69f7674ea7ce034350dc714824
Rust
nikhilm/vignette
/vignette/src/bin/generate_symbols.rs
UTF-8
1,656
2.734375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
// Generates a symbol file in a given location, assuming dump_syms is in the path. use std::io::BufRead; use std::io::BufReader; use std::io::Cursor; use std::io::Write; use std::path::{PathBuf}; fn main() { let mut args = std::env::args(); args.next().expect("the program itself"); let binary = args.next(...
true
206043ec392e456be52cae39775b07cc709a28bc
Rust
fnuttens/rust_katas
/src/reducing_by_steps.rs
UTF-8
1,804
3.375
3
[]
no_license
use std::cmp; fn som(x: i64, y: i64) -> i64 { x + y } fn maxi(x: i64, y: i64) -> i64 { cmp::max(x, y) } fn mini(x: i64, y: i64) -> i64 { cmp::min(x, y) } fn gcdi(m: i64, n: i64) -> i64 { if n == 0 { return m.abs(); } else { let r = m % n; return gcdi(n, r).abs(); } } fn ...
true
0eafefbb1488e67e2a897bf202cd4ce64d8c8bb2
Rust
yzhong52/AdventOfCode
/2019/src/y2019/day19.rs
UTF-8
1,781
3.28125
3
[]
no_license
use super::super::helpers::parser::*; use crate::int_code_computers::super_int_code_computer::SuperIntCodeComputer; use crate::int_code_computers::super_int_code_computer::SuperIntCodeResult; use crate::helpers::puzzle::Puzzle; fn test_location(x: i128, y: i128, data: &Vec<i128>) -> i128 { let mut drone = SuperInt...
true
0f90eb5779912d95e7be848f900802287602cf26
Rust
happysalada/poem
/examples/poem/tonic/src/main.rs
UTF-8
1,226
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
use hello_world::{ greeter_server::{Greeter, GreeterServer}, HelloReply, HelloRequest, }; use poem::{endpoint::TowerCompatExt, listener::TcpListener, Route, Server}; use tonic::{transport::NamedService, Request, Response, Status}; pub mod hello_world { tonic::include_proto!("helloworld"); } pub struct MyG...
true
51f14fed4103a5c8889063d0e4b67ebe655c3276
Rust
nathanfaucett/rs-lisp
/src/loader/dylib.rs
UTF-8
2,931
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::cmp::Ordering; use std::fmt; use std::hash::{Hash, Hasher}; use std::ops::Deref; use std::ptr; use gc::{Gc, Trace}; use libloading::{Error, Library, Symbol}; use runtime::{ add_external_function, new_kind, new_object, scope_get_with_kind, scope_set, Keyword, Kind, Object, Scope, Value, Vector, }; pub typ...
true
e9b1acc183502cae9c34482accf3c076f99ea132
Rust
ax-lab/v1-kana
/src/table.rs
UTF-8
20,107
3.234375
3
[ "MIT" ]
permissive
//! Internal table used for kana conversions. //! //! Modified from //! https://github.com/PSeitz/wana_kana_rust/blob/master/src/constants.rs use fnv::FnvHashMap; use fnv::FnvHashSet; macro_rules! hashmap { (@single $($x:tt)*) => (()); (@count $($rest:expr),*) => (<[()]>::len(&[$(hashmap!(@single $rest)),...
true
c5a6835757ca89a61e9244509f32b232dd02a830
Rust
KonishchevDmitry/investments
/src/commissions/builders.rs
UTF-8
5,726
2.890625
3
[]
no_license
use std::collections::BTreeMap; use crate::core::GenericResult; use crate::types::{Decimal, TradeType}; use crate::util::RoundingMethod; use super::{ CommissionSpec, TradeCommissionSpec, TransactionCommissionSpec, CumulativeCommissionSpec, CumulativeTierType, CumulativeTieredSpec, CumulativeFeeSpec }; pub st...
true
0859150b148a237743a5d66d43f3ce6a37b504a6
Rust
imor/zeno
/src/path_builder.rs
UTF-8
19,173
3.359375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Path builder. use super::command::Command; use super::geometry::{Angle, BoundsBuilder, Point, Transform}; use crate::lib::Vec; /// Describes the size of an arc. #[derive(Copy, Clone, PartialEq)] pub enum ArcSize { /// An arc of <= 180 degrees will be drawn. Small, /// An arc of >= 180 degrees will be...
true
ca389f69bffdfd860e930a1189a88903e1826d9f
Rust
hgzimmerman/HLWNPA
/src/ast/type_checking.rs
UTF-8
29,632
3.015625
3
[]
no_license
use ast::abstract_syntax_tree::Ast; use ast::type_info::TypeInfo; use std::collections::HashMap; use ast::s_expression::SExpression; #[derive(Debug, Clone, PartialEq)] pub enum TypeError { TypeMismatch(TypeInfo, TypeInfo), UnsupportedOperation(TypeInfo, TypeInfo), LhsNotAnIdentifier, IdentifierDoesntEx...
true
b0dec768bc016e66e6f9ee40972a4b62ac4079d4
Rust
rcore-os-infohub/ossoc2020-VitalyAnkh-daily
/Rust/rustua/src/main.rs
UTF-8
107
3
3
[]
no_license
fn main() { println!("Hello, world!"); let x=1; let b=Box::new(x); println!("{:p}",b); }
true
b87b814db9ea10591425326ed22c132969e43eeb
Rust
aguestuser/rust-book
/vectors/src/main.rs
UTF-8
768
3.4375
3
[]
no_license
fn main() { // declaration let _v1: Vec<i32> = Vec::new(); let v2 = vec![1, 2, 3]; let mut v3 = Vec::new(); v3.push(1); v3.push(2); v3.push(3); // value extraction let _third: &i32 = &v2[2]; let _third: Option<&i32> = v2.get(2); //let _boom = &v2[1000]; let _none = v2...
true
b061bbeb3e7a9c88a63a912022b82c1d4689f15d
Rust
tshepang/tree-buf
/tree-buf/src/internal/types/array_fixed.rs
UTF-8
8,654
2.6875
3
[ "MIT" ]
permissive
macro_rules! impl_fixed { ($(($size:expr, $namespace:ident)),+) => { $(mod $namespace { use crate::prelude::*; use std::mem::{MaybeUninit}; // This transmute is a (seriously unsafe) version // of std::mem::transmute which allows unmatched sizes // ...
true
66cdfc46ab66f6572b482f680d2c2d0f9d6fd7a8
Rust
lyswifter/forest
/forest/src/cli/net_cmd.rs
UTF-8
4,343
2.546875
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2019-2022 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT use forest_libp2p::{Multiaddr, Protocol}; use rpc_api::data_types::AddrInfo; use std::collections::HashSet; use structopt::StructOpt; use crate::cli::cli_error_and_die; use super::{handle_rpc_err, print_stdout}; use rpc_client::net_...
true
255194d65724809f0570583079b0e2e739ff0240
Rust
sile/erl_ast
/src/ast/clause.rs
UTF-8
651
2.640625
3
[ "MIT" ]
permissive
//! Clauses //! //! See: [6.5 Clauses](http://erlang.org/doc/apps/erts/absform.html#id88135) use ast; use ast::expr; use ast::guard; use ast::pat; #[derive(Debug, Clone)] pub struct Clause { pub line: ast::LineNum, pub patterns: Vec<pat::Pattern>, pub guards: Vec<guard::OrGuard>, pub body: Vec<expr::Ex...
true
8fe6e4b9623a61b69ced1c96836f981053ecb33e
Rust
zed-ui/zed-ui
/zui-shared/src/sys/macos.rs
UTF-8
750
2.703125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::{ ffi::CStr, fmt, }; use cocoa::{ base::nil, foundation::NSString, }; use objc::rc::StrongPtr; #[derive(Clone)] pub struct ZedString { pub ns_string: StrongPtr } impl fmt::Debug for ZedString { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { unsafe { self.as_utf8_temp(...
true
edadcf59a552cf51dd54318cce4893156390eaa1
Rust
whidbey/queen
/src/time/mod.rs
UTF-8
1,233
3.09375
3
[ "MIT" ]
permissive
use std::time::{Duration, SystemTime, UNIX_EPOCH}; use std::collections::VecDeque; pub struct Wheel<T> { wheel: Vec<Vec<Task<T>>>, tick_ms: usize, tick_num: usize, cur_index: usize, cur_time: Duration } #[derive(Clone, Debug)] pub struct Task<T> { pub data: T, pub time: Duration, pub i...
true
24df24fa013b6876a3c8cfdd2bab7e98cc14ba69
Rust
joshwlewis/adventofcode
/2019.02/src/main.rs
UTF-8
2,127
3.53125
4
[]
no_license
use std::io::{self, Read}; fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); let incode: Vec<usize> = input.split(',').filter_map(|i| i.trim().parse::<usize>().ok() ).collect(); println!("Input:\n {:?}", incode); let alarmcode = set_input(&inc...
true
77a21d84a8f843e1656fae0b055f3da9ff576f5e
Rust
agelito/rust-snake
/src/main_menu.rs
UTF-8
2,151
3.234375
3
[]
no_license
use super::game_state::State; use super::renderer::Renderer; use super::snake_game::SnakeGame; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; pub struct MainMenu { selected: usize, buttons: Vec<String>, color: Color, selected_color: Color, play: bool, quit: bool, } impl MainMenu { ...
true
8b6cef93f48b3c36b760d7f2ab9bd7b72a722015
Rust
cyrilguerard/sudoku
/src/board.rs
UTF-8
7,356
2.8125
3
[]
no_license
use std::fmt::{Debug, Formatter, Result}; use crate::board::Cell::{Fixed, Free}; use bitmask::bitmask; pub const BOARD_BOX_SIZE: usize = 3; pub const BOARD_SIZE: usize = BOARD_BOX_SIZE * BOARD_BOX_SIZE; bitmask! { mask FreeNumberMask: u16 where flags FreeNumberFlags { _0 = 0, // unused to easy index ...
true
f54e91a9a47533d08f8f22cb36f97fcd533fa1d0
Rust
martinaAgata/21C1-Rust-eze
/src/commands/keys/del.rs
UTF-8
3,661
3.234375
3
[]
no_license
use crate::native_types::error_severity::ErrorSeverity; use crate::{ commands::{check_empty, check_not_empty, Runnable}, database::Database, messages::redis_messages, native_types::{ErrorStruct, RInteger, RedisType}, }; use std::sync::{Arc, Mutex}; pub struct Del; impl Runnable<Arc<Mutex<Database>>> f...
true
0479005dddf716df5dcda755862c08229c5af523
Rust
ayazhafiz/slide
/editor/language_server/src/program/services/folding_ranges.rs
UTF-8
923
2.75
3
[ "BSD-3-Clause" ]
permissive
//! Module `folding_ranges` provides service to determine ranges that a user may want to fold in a //! slide program. use super::response::*; use crate::Program; use libslide::visit::StmtVisitor; use libslide::*; impl Program { /// Returns [span](Span)s of foldable ranges in a program. /// Such ranges genera...
true
5a296da443798db4d269b5c67021800946a6ec64
Rust
hibi221b/ls-tiny
/src/lib.rs
UTF-8
3,743
3.921875
4
[ "MIT" ]
permissive
//! **ls-tiny** is a less functional `ls` command //! it is somewhat richer than when no argument to the ls command is specified. (Because it's a little colored.) #[macro_use] extern crate clap; use clap::{Arg, App}; use colored::Colorize; use std::path::{Path, PathBuf}; /// The Config structure has four fields /// *...
true
046d9667ec716b607d3a235693f7f1d291ad81ba
Rust
Kixiron/lasso
/src/interface/rodeo_reader.rs
UTF-8
1,850
2.78125
3
[ "Apache-2.0", "MIT" ]
permissive
//! Implementations of [`Reader`] and [`Resolver`] for [`RodeoReader`] use crate::{IntoResolver, Key, Reader, Resolver, RodeoReader, RodeoResolver}; #[cfg(feature = "no-std")] use alloc::boxed::Box; use core::hash::BuildHasher; impl<K, S> Reader<K> for RodeoReader<K, S> where K: Key, S: BuildHasher, { #[c...
true
8feb81af2dae877a738bfc02fcf2f5708d125fe2
Rust
AffogatoLang/Moka-Conf
/src/util/file_util.rs
UTF-8
501
2.59375
3
[]
no_license
use std::env; use std::path::Path; use std::io; use std::io::Write; use std::fs; pub fn get_pwd() -> String { env::var("PWD").unwrap() } pub fn get_pwd_name() -> String { let pwd = env::var("PWD").unwrap(); let pwd_path = Path::new(&pwd); (&(*(pwd_path.file_name().unwrap()).to_str().unwrap())).to_strin...
true
5d44979948d571b12f97a5bcc4f932d06448c228
Rust
carbidegames/soto
/soto-fbx/src/smd.rs
UTF-8
10,859
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::fs::File; use std::io::{BufReader}; use std::path::PathBuf; use cgmath::{Matrix4, Deg, Vector4, SquareMatrix, Vector3, Euler, Quaternion, Rotation}; use soto::task::{task_log}; use soto::Error; use sotolib_fbx::{RawFbx, id_name, friendly_name, ObjectTreeNode}; use sotolib_fbx::animation::{Animation}; use soto...
true
87993d86abe2563ab93308231dfce81ea1019b50
Rust
liamom/c_game
/game/src/main.rs
UTF-8
958
2.609375
3
[]
no_license
extern crate rand; #[macro_use] extern crate log; extern crate env_logger; extern crate engine; mod name_generator; mod gfx; mod my_app; use std::result::Result; use name_generator::*; use engine::error::GameError; fn rec(i: i32)->i32 { match i { 0 => {1} _ => {i+rec(i-1)} } } fn main() { ...
true
bbfd91e24c4a4efc7cc923806ca9e429a88f2e41
Rust
alvinmatias69/bencode
/src/encoder/number.rs
UTF-8
413
3.953125
4
[]
no_license
pub fn parse(num: i64) -> String { let mut result = String::from("i"); result.push_str(&num.to_string()); result.push('e'); result } #[cfg(test)] mod test { use super::*; #[test] fn should_return_given_number() { // given let num: i64 = 420; // when let res...
true
ee63b0aa6314b43154786bf2808e34ef3585257b
Rust
expobrain/mars-robot
/src/setup.rs
UTF-8
2,069
3.296875
3
[ "MIT" ]
permissive
use std::fs::File; use std::path::Path; use std::io::prelude::*; use robot::Instructions; use engine::{Movements, Point, Size, Vector}; #[derive(Debug)] pub struct Setup { pub size: Size, pub instructions: Vec<Instructions>, } fn parse_size(buffer: &str) -> Size { let values = buffer .lines() ...
true
d13a1033355cb65f1e328fb040628207e644b88a
Rust
tje/duration-parser
/src/unit.rs
UTF-8
1,413
3.546875
4
[]
no_license
use crate::util::constants::{ WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND, }; #[derive(Debug, PartialEq)] pub enum Unit { Week, Day, Hour, Minute, Second, Millisecond, } impl Unit { pub fn from_str(s: &str) -> Option<Self> { let u = s.to_lowercase(); if u == "w" || u == "wk" || u.st...
true
92812273c294a0ec746910be9798ae481ec48319
Rust
Viphor/POOP
/src/parser/ast.rs
UTF-8
12,178
3.453125
3
[]
no_license
//! This module contains the structures needed to form the Abstract Syntax Tree (AST) //! formed by the [`Parser`] (see for EBNF). use super::error::ParserError; use super::Output; use super::Parser; use super::Source; use super::{Token, Tokens}; use std::fmt; use std::ops::Deref; use std::str; /// Wrapper type to he...
true
570834e30c567deecdd2020f73065952feafd2ed
Rust
notriddle/mozjs-example
/src/main.rs
UTF-8
554
2.578125
3
[]
no_license
use mozjs_example::run_js; use std::io::{stdin, Stdin}; use smol; trait LinesTrait: Sized { fn lines(self) -> Lines; } impl LinesTrait for Stdin { fn lines(self) -> Lines { Lines { r: self } } } struct Lines { r: Stdin, } impl Iterator for Lines { type Item = String; fn next(&mut self) -> Option...
true
52420b4f57e17240f34b5c317f164ba3e1286f5f
Rust
seansu4you87/hello-rust
/fizzbuzz.rs
UTF-8
922
3.84375
4
[]
no_license
fn div_by_three(num: int) -> bool { num % 3 == 0 } fn div_by_five(num: int) -> bool { num % 5 == 0 } fn div_by_fifteen(num: int) -> bool { num % 15 == 0 } fn main() { for num in range(1i, 101) { println!("{:s}", if div_by_fifteen(num) { "FizzBuzz" } else if div_by_three(num) { "Fizz" } ...
true
08a39c92ce94a05e340a48c910d5355522deef8e
Rust
Genymobile/gnirehtet
/relay-rust/src/execution_error.rs
UTF-8
4,323
2.5625
3
[ "Apache-2.0" ]
permissive
/* * Copyright (C) 2017 Genymobile * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed ...
true
bbdd672f89522aada781f2c555025ee880be4ff1
Rust
dirvine/crdt_tree
/src/logopmove.rs
UTF-8
3,625
2.84375
3
[ "BSD-3-Clause", "MIT" ]
permissive
// Copyright 2020 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT // http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD // https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied, // modified, or di...
true
727bad09abce3b9a59a548a355bf1a2268089fa0
Rust
safai-labs/sled
/src/frag.rs
UTF-8
983
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
use super::*; /// Frag denotes a tree node or its modification fragment such as /// key addition or removal. /// /// /// TODO: /// Merged /// LeftMerge(head: Raw, rhs: PageId, hi: Bound) /// ParentMerge(lhs: PageId, rhs: PageId) /// TxBegin(TxID), // in-mem /// TxCommit(TxID), // in-mem /// TxA...
true
4f1226070613e4c5dfe21f6a2e1eec2b47eb5590
Rust
notdanilo/gpu
/src/context/platform/web.rs
UTF-8
2,347
2.71875
3
[]
no_license
#![allow(missing_docs)] use crate::context::ContextBuilder; use web_sys::HtmlCanvasElement; use wasm_bindgen::JsCast; use crate::{GLContext, HasContext, HasGLContext}; /// Web Contexts doesn't emit any error. pub type ContextError = (); // =============== // === Context === // =============== //TODO: Context shoul...
true
a11eec3dbd969b8f6054e6dfc0f76da63664a3c3
Rust
ConnorBP/rust-voxel-data
/src/mosaic/solid.rs
UTF-8
881
2.984375
3
[ "MIT" ]
permissive
//! A mosaic with only a single material. use cgmath::{Point3, Vector3}; use field; use mosaic; #[derive(Debug, Clone, Copy)] #[allow(missing_docs)] pub struct T<Material, Field> { pub field: Field, pub material: Material, } unsafe impl<Material, Field> Send for T<Material, Field> where Field: Send {} impl<Mat...
true
e45ce52862e66925eab0a67055ce752bfdf8ccef
Rust
nimiq/core-rs
/network/src/websocket/reverse_proxy.rs
UTF-8
5,187
2.828125
3
[ "Apache-2.0" ]
permissive
use std::str::from_utf8; use std::str::FromStr; use std::sync::Arc; use parking_lot::Mutex; use reqwest::StatusCode; use tungstenite::handshake::server::{Callback, ErrorResponse, Request}; use network_primitives::address::NetAddress; use crate::network_config::ReverseProxyConfig; /// Struct that stores relevant dat...
true
1fff2ae4a93e019f38aea34dbbc89f54f20a22b3
Rust
akhali11/habitat
/components/sup/src/manager/service/dir.rs
UTF-8
5,841
2.625
3
[ "Apache-2.0" ]
permissive
// Copyright (c) 2018 Chef Software Inc. and/or applicable contributors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless r...
true
13e4ea353b9543fd134391bbcc7da4735efe2905
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/sec1-0.2.1/src/parameters.rs
UTF-8
2,190
2.890625
3
[ "Apache-2.0", "MIT", "BSD-2-Clause" ]
permissive
use der::{ asn1::{Any, ObjectIdentifier}, DecodeValue, Decoder, EncodeValue, Encoder, FixedTag, Length, Tag, }; /// Elliptic curve parameters as described in /// [RFC5480 Section 2.1.1](https://datatracker.ietf.org/doc/html/rfc5480#section-2.1.1): /// /// ```text /// ECParameters ::= CHOICE { /// namedCurve ...
true
1628311a19ac0401f8e5948eef0c2d7ab016d054
Rust
Korvox/qml-rust
/examples/resources/src/main.rs
UTF-8
1,014
2.8125
3
[ "MIT" ]
permissive
extern crate qml; use std::cell::UnsafeCell; use std::marker::Sync; use std::thread; use std::time; use std::sync::Arc; use qml::*; struct NotThreadSafe<T> { value: UnsafeCell<T>, } // The unsafe code is needed to make QmlEngine multithreadedd, since I am not sure, whether should this be in a library. // The si...
true
29d5d6a6ad49278bb578088ecbd6c178b58fd273
Rust
ul/sound-garden-2
/synth-modules/src/sample.rs
UTF-8
523
2.78125
3
[]
no_license
//! # Basic audio signal types /// The type which modules talk to each other. /// /// Rationale behind choosing f64 over f32 despite the fact that most of audio drivers work with /// f32 is that when you create a composite module signal experiences a lot of transformations and /// the less is rounding error accumulati...
true
54657a48c480e85b556d0cde7941ac00af1dc0a5
Rust
thanatos/cq
/src/out_json.rs
UTF-8
2,317
3.171875
3
[]
no_license
use std::convert::TryFrom; use std::error::Error; use std::io::Write; use serde_cbor::Value; use serde_json::Value as JsonValue; pub fn output_json<W: Write>(output: W, value: Value) -> Result<(), Box<dyn Error>> { serde_json::to_writer(output, &to_json(&value))?; Ok(()) } fn to_json(value: &Value) -> serde_...
true
75c2cc8c45f0515c2934ff0b2a71c6085298b9b1
Rust
la10736/advent_of_code_day17
/src/main.rs
UTF-8
3,029
3.609375
4
[]
no_license
fn main() { let step = std::env::args() .nth(1) .unwrap_or("3".to_string()) .parse() .unwrap(); let sequence = spinlock_history(2018, step); let &(_, last) = sequence.last().unwrap(); let result = resolve_value(&sequence, last + 1).unwrap(); println!("Result = {}",...
true
55762776c22c8085345ab76c913bd7f0cf27266b
Rust
Jakur/advent2019
/src/lib.rs
UTF-8
1,503
2.796875
3
[]
no_license
pub use std::cmp::{max, min}; pub use std::collections::{HashMap, HashSet}; pub use std::fmt; pub mod intcode; pub use intcode::{parse_intcode, IntMachine}; pub mod p1; pub mod p10; pub mod p11; pub mod p12; pub mod p13; pub mod p14; pub mod p15; pub mod p2; pub mod p3; pub mod p4; pub mod p5; pub mod p6; pub mod p7;...
true
463c81af2add0a0618f7e50e9dbcc07d6f76e3d1
Rust
overdrivenpotato/rust
/src/tools/clippy/clippy_lints/src/as_underscore.rs
UTF-8
2,344
2.796875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, TyKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_too...
true
14e77dd3889ab02a4432c02d9113a11b15a58818
Rust
jeffparsons/rangemap
/src/inclusive_set.rs
UTF-8
16,159
3.3125
3
[ "MIT", "Apache-2.0" ]
permissive
use core::cmp::Ordering; use core::fmt::{self, Debug}; use core::iter::FromIterator; use core::ops::RangeInclusive; #[cfg(feature = "serde1")] use core::marker::PhantomData; #[cfg(feature = "serde1")] use serde::{ de::{Deserialize, Deserializer, SeqAccess, Visitor}, ser::{Serialize, Serializer}, }; use crate:...
true
2c3d59c42e91f89016751d76c1951d5dad1b53e3
Rust
perlindgren/probe-rs
/probe-rs/src/error.rs
UTF-8
1,124
2.65625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::DebugProbeError; use crate::{architecture::arm::ap::AccessPortError, config::RegistryError}; #[derive(thiserror::Error, Debug)] pub enum Error { #[error("An error with the usage of the probe occured")] Probe(#[from] DebugProbeError), #[error("A core architecture specific error occured")] Arc...
true
1dd47feb14b613112b5715d877736ab5fcbefbea
Rust
gabriel-araujjo/ad-hoc-parse-tables
/src/data/page.rs
UTF-8
7,723
3.09375
3
[]
no_license
use std::{ fmt::{Debug, Display}, str::FromStr, }; use super::Range; #[derive(PartialEq, Eq, PartialOrd, Ord)] pub struct Page(Range); impl From<Range> for Page { fn from(r: Range) -> Self { Page(r) } } impl FromStr for Page { type Err = (); fn from_str(s: &str) -> Result<Self, Self...
true
650078f6b78b063a203250d3fa10e9f0bf41f5d7
Rust
joshuaclayton/date-calculations
/src/lib.rs
UTF-8
10,602
3.671875
4
[ "MIT" ]
permissive
#![deny(missing_docs)] //! This crate provides helper functions for calculating shifts in Chrono's NaiveDate values for //! various periods (week, month, quarter, year) for common shifts in direction (beginning_of_*, //! end_of_*, previous_*, and next_*). //! //! The dates passed to these functions should be Gregorian...
true
533c3e6ee4c2722706e7699b76ce0de192000301
Rust
pyk/Crabsformer
/src/lib.rs
UTF-8
13,930
3.5
4
[ "Apache-2.0" ]
permissive
// Copyright (c) 2019, Bayu Aldi Yansyah <bayualdiyansyah@gmail.com> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless requ...
true
b970d75a03d7724c92d5764520bd70b628fcfbc0
Rust
sim82/squirrel-rs
/src/io.rs
UTF-8
6,782
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
use super::{object, Error, FileTags, Object, ObjectType, Result}; use crate::bytecode::Instruction; use byteorder::{LittleEndian, ReadBytesExt}; use num_traits::{FromPrimitive, ToPrimitive}; use std::io::Read; use std::rc::Rc; fn read_string(rdr: &mut dyn Read) -> Result<Object> { let len = rdr.read_u64::<LittleE...
true
55073d9e2628ea12c78d41146d9baee7439c8192
Rust
schets/ExclusivePtr
/src/exclusive_target/cas_impl/exclusive_64.rs
UTF-8
8,341
3.09375
3
[ "MIT" ]
permissive
/// Like mem::epoch::AtomicPtr, but provides an ll/sc based api on x86, powerpc, arm, aarch64 use std::mem; use std::marker::PhantomData; use std::sync::atomic::{Ordering, AtomicUsize}; #[cfg(target_pointer_width = "64")] mod multi_size { pub const PTR_MOD: usize = 15; #[inline(always)] pub unsafe fn c...
true
41d5ab81da85b9128024bcf90b79ab0446bc3dc6
Rust
hfjallemark/serverside-rust
/src/db/posts.rs
UTF-8
960
2.703125
3
[]
no_license
use crate::db::Db; use crate::models::{NewPost, Post}; use postgres::rows::Row; use postgres::Result; impl Db { pub fn add_post(self: &Db, new: &NewPost, _: i64) -> Result<Post> { self.query_one( sql!("add_post"), &[&new.content, &new.resource_id, &new.resource_type], Po...
true
cb2970c5f2ac26bb3e5f885b006378dc474c3693
Rust
gimli-rs/gimli
/src/read/addr.rs
UTF-8
4,323
3.0625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::common::{DebugAddrBase, DebugAddrIndex, SectionId}; use crate::read::{Reader, ReaderOffset, Result, Section}; /// The raw contents of the `.debug_addr` section. #[derive(Debug, Default, Clone, Copy)] pub struct DebugAddr<R> { section: R, } impl<R: Reader> DebugAddr<R> { // TODO: add an iterator ove...
true
c81c22bfae38cbe55a74f4ead68e378db8a1805d
Rust
aGiant/robust_trading.icml2019
/rstat/src/univariate/continuous/chi_sq.rs
UTF-8
2,799
2.90625
3
[ "BSD-3-Clause", "MIT" ]
permissive
use crate::core::*; use rand; use spaces::continuous::PositiveReals; use std::fmt; #[derive(Debug, Clone, Copy)] pub struct ChiSq { pub k: usize, } impl ChiSq { pub fn new(k: usize) -> ChiSq { ChiSq { k } } } impl Into<rand::distributions::ChiSquared> for ChiSq { fn into(self) -> rand::distri...
true
254a6177a0f3e206699d0f5d272079942fb42266
Rust
cruelnoise/ass2ass
/src/ass/style.rs
UTF-8
8,683
3.046875
3
[]
no_license
use self::Token::*; use super::common::{Alignment, BorderStyle, Encoding, ABGR}; use super::AssParseError::{self, BadAssBool, BadStyleToken, StyleNotMatchFormat}; use parse_display::Display; use std::{fmt, str::FromStr}; #[derive(Display, Debug, Clone, Copy, PartialEq)] enum Token { Name, Fontname, Fontsiz...
true
219315e3c8a126d480ffcf68d77a64b48b61a22a
Rust
j-dsouza/rust-advent-of-code
/basics/branches/src/main.rs
UTF-8
450
3.84375
4
[]
no_license
fn main() { let number = 90; if number % 4 == 0 { println!("Number is divisible by 4"); } else if number % 3 == 0 { println!("Number is divisible by 3"); } else if number % 2 == 0 { println!("Number is divisible by 2"); } else { println!("Number not divisible by 2, 3...
true
120089b721ba14d2337f33274d759fe80da4fcfd
Rust
haochuan/aoc-2020
/src/day2.rs
UTF-8
2,805
3.265625
3
[]
no_license
extern crate regex; use regex::Regex; // use std::collections::HashMap; pub struct Password { required_char: char, // min and max may be confused in part 2, // since it's position index min: usize, max: usize, content: String, } #[aoc_generator(day2)] pub fn input_generator(input: &str) -> Vec...
true
0c60f559abf318e4547ed6c97eae39206f2670b8
Rust
lavoiee/rust-basic-1
/src/pointer_ref.rs
UTF-8
570
4.15625
4
[]
no_license
pub fn run() { // Primitive Array let arr1 = [1,2,3]; let arr2 = arr1; /* With non-primitives, if you assign another varianle to a piece of data, the first variable will no longer hold that value. You'll need to use a reference (&) to the resource. */ println!("Values: {:?}", (a...
true
c1bc13c2b1e92afd0f33c005487d59fe8528c961
Rust
IThawk/rust-project
/rust-master/src/test/ui/rfc1445/issue-62307-match-ref-ref-forbidden-without-eq.rs
UTF-8
1,557
3.171875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// RFC 1445 introduced `#[structural_match]`; this attribute must // appear on the `struct`/`enum` definition for any `const` used in a // pattern. // // This is our (forever-unstable) way to mark a datatype as having a // `PartialEq` implementation that is equivalent to recursion over its // substructure. This avoids ...
true
eb9160bc5e009abad07b87b2b58f7cda4b4b9dde
Rust
dummycode/rustos
/lib/fat32/src/vfat/file.rs
UTF-8
4,352
2.890625
3
[]
no_license
use alloc::string::String; use shim::io::{self, SeekFrom, Error, ErrorKind}; use crate::traits; use crate::vfat::{VFat, Cluster, Metadata, VFatHandle}; #[derive(Debug)] pub struct File<HANDLE: VFatHandle> { pub vfat: HANDLE, pub metadata: Metadata, starting_cluster: Cluster, curr_cluster: Option<Clus...
true
962b47d19a7b4c0e4b21ad6a3488991169dec45a
Rust
nouvadam/pathtracer
/src/misc/pdf.rs
UTF-8
3,067
3.34375
3
[ "MIT" ]
permissive
//! Struct representing probability density function pub use crate::hit::*; pub use crate::misc::Onb; pub use crate::primitive::*; pub use crate::V3; use objekt_clonable::*; /// Represents probability density function //#[clonable] #[enum_dispatch(Primitive)] pub trait Pdf { /// Gives value of this Pdf for given ...
true
a5be265b9374b4e538a72accffdc6cf5067402c4
Rust
dduchen/rs-gfatovcf
/src/bubble_detection.rs
UTF-8
21,352
2.953125
3
[]
no_license
use handlegraph::handle::{Direction, Edge, Handle, NodeId}; use handlegraph::handlegraph::HandleGraph; use handlegraph::handlegraph::{handle_edges_iter, handles_iter}; use handlegraph::hashgraph::HashGraph; use handlegraph::hashgraph::PathId; use handlegraph::mutablehandlegraph::MutableHandleGraph; use handlegraph::pat...
true
2b8797c9aa2a05c5ba2f90e4ee8896a87529e1bd
Rust
nisarhassan12/materialize
/src/ore/src/collections.rs
UTF-8
4,261
3.015625
3
[ "Apache-2.0", "BSD-2-Clause", "CC0-1.0", "BSD-3-Clause", "MPL-2.0", "0BSD", "PostgreSQL", "GPL-1.0-or-later", "GPL-2.0-only", "MIT", "BUSL-1.1" ]
permissive
// Copyright Materialize, Inc. and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License in the LICENSE file at the // root of this repository, or online at // /...
true
9df1128df419d84d12570d7f5afc19aa351166a1
Rust
tyukiand/frosty
/frostyvm/src/process.rs
UTF-8
22,682
2.84375
3
[]
no_license
use crate::built_in::BuiltInChannel; use crate::comm_queue::CommQueue; use crate::prettyprint::PrettyPrintable; use crate::prettyprint::PrettyPrintable::*; use std::fmt; use std::fmt::Display; use uuid::Uuid; #[derive(Clone, Debug, PartialEq)] pub enum ProcCons<Binders> { Parallel(Vec<ProcCons<Binders>>), Unf...
true
a47b9f704d545e1ce4a962cf2ddf23d68886635a
Rust
DonghyungKo/Rust
/the-programming-language-rust/ch19_advanced/lifetime/src/lib.rs
UTF-8
2,930
3.828125
4
[]
no_license
// 고급 라이프타임 // 모든 참조자는 수명을 갖지만, 거의 대부분의 경우 러스트가 라이프타임을 생략하도록 해준다 // 라이프 타임의 세가지 고급 기능 // 1. 라이프타임 서브타이핑(subtyping): 한 라이프타임이 다른 라이프타임보다 오래 사는 것을 보장 // 2. 라이프타임 바운드: 제네릭 타입을 가르키는 참조자를 위한 라이프타임 명시하기 // 3. 트레잇 객체 라이프타임 추론: 컴파일러가 어떻게 트레잇 객체의 라이프타임을 추론하며, 언제 명시해야 할지 // 라이프타임 서브타이핑은 하나의 라이프타임이 다른 것보다 오래 사는 것을 보장합니다. // 라이프...
true
15a1bbb1f4cfe3cbce7b98b7f7db8b613128f744
Rust
afck/crosswords-rs
/src/test_util.rs
UTF-8
306
3.28125
3
[ "MIT" ]
permissive
#![cfg(test)] /// Converts a `str` to a `Vec<char>`. pub fn str_to_cvec<T: AsRef<str>>(s: T) -> Vec<char> { s.as_ref().chars().collect() } /// Converts a slice of `&str`s to a `Vec<Vec<char>>`. pub fn strs_to_cvecs(strs: &[&str]) -> Vec<Vec<char>> { strs.into_iter().map(str_to_cvec).collect() }
true
52243e209f782d0c1884a3fb324c02db1c5ab080
Rust
armersong/eureka-rs
/src/instance.rs
UTF-8
3,381
2.921875
3
[]
no_license
pub use rest::structures::{Instance, PortData, StatusType}; use rest::EurekaRestClient; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::thread; use std::time::Duration; use EurekaError; #[derive(Debug)] pub struct InstanceClient { client: Arc<EurekaRestClient>, config: Arc<Instance>...
true
d6be9521a722f7b42ffd563204968bd67e7cfa50
Rust
wormtql/hex-rust
/src/simulator/plain_simulator.rs
UTF-8
1,173
3
3
[]
no_license
use super::{Simulator}; use crate::board::{Board, Color}; use rand::prelude::*; pub struct PlainSimulator { } impl PlainSimulator { pub fn new() -> PlainSimulator { PlainSimulator {} } } impl Simulator for PlainSimulator { fn simulate(&self, board: &Board, next_player: Color) -> Color { ...
true
4007be35b93e8bad7ffeb80b24fc2b26ec17dc76
Rust
ThomasdenH/casimir-fdfd
/src/world/mod.rs
UTF-8
12,118
3.28125
3
[ "MIT" ]
permissive
mod boundingbox; mod material; mod shape; use crate::config::SimulationConfig; use crate::fields::ScalarField; use crate::greenfunctions::cosinebasis::{CosineBasis, Direction}; use crate::world::boundingbox::BoundingBox; use crate::world::shape::Shape; use nalgebra::*; use pbr::ProgressBar; use rayon::iter::*; use ser...
true
39f4fcca821a34a8166b817e86fad6c1da627d71
Rust
rezural/smithay
/src/wayland/tablet_manager/tablet_seat.rs
UTF-8
6,645
2.609375
3
[ "MIT" ]
permissive
use wayland_protocols::unstable::tablet::v2::server::zwp_tablet_seat_v2::ZwpTabletSeatV2; use wayland_server::{Filter, Main}; use crate::backend::input::TabletToolDescriptor; use crate::wayland::seat::CursorImageStatus; use super::tablet::{TabletDescriptor, TabletHandle}; use super::tablet_tool::TabletToolHandle; us...
true
bf0d75146cf04c208c92900ed9b7a34472cf9253
Rust
gre/gre
/plots/examples/wip_wedcards/main.rs
UTF-8
12,131
2.515625
3
[ "LicenseRef-scancode-proprietary-license", "CC-BY-4.0", "MIT" ]
permissive
use clap::*; use gre::*; use noise::*; use rand::prelude::*; use rayon::prelude::*; use std::f64::consts::PI; use svg::node::element::path::Data; use svg::node::element::*; #[derive(Parser)] #[clap()] pub struct Opts { #[clap(short, long, default_value = "image.svg")] file: String, #[clap(short, long, default_va...
true
c5590e374b499d42a3674ddcb83689161f5fc85a
Rust
magiclen/enum-ordinalize
/src/panic.rs
UTF-8
828
3.09375
3
[ "MIT" ]
permissive
#[inline] pub fn not_enum() -> ! { panic!("Only enums can be ordinalized.") } #[inline] pub fn not_unit_variant() -> ! { panic!("An ordinalized enum can only have unit variants.") } #[inline] pub fn no_variant() -> ! { panic!("An ordinalized enum needs to have at least one variant.") } #[inline] pub fn u...
true
f53ee461cf21e42e1d83c6bf2bc5279b9ea98837
Rust
rkjk/mit-6824
/mapreduce/src/main.rs
UTF-8
1,649
3.359375
3
[]
no_license
mod master; mod wc; mod worker; use std::path::PathBuf; use std::time::Instant; use serde::{Deserialize, Serialize}; use std::cmp::{Eq, PartialEq}; #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] pub enum Task { Map, Reduce, Wait, Exit, } #[derive(Serialize, Deserialize, Debug)] pub s...
true
e929d2599ff03131c3e1dcf5dd777b6905ee8572
Rust
pedantic79/Exercism
/rust/simple-linked-list/src/lib.rs
UTF-8
1,822
3.84375
4
[]
no_license
pub struct SimpleLinkedList<T> { head: NodePtr<T>, } struct Node<T> { data: T, next: NodePtr<T>, } type NodePtr<T> = Option<Box<Node<T>>>; impl<T> Default for SimpleLinkedList<T> { fn default() -> Self { Self { head: None } } } impl<T> SimpleLinkedList<T> { pub fn new() -> Self { ...
true
66d43f2c3cb4cf02e8a927c0fd9be062f5a15d06
Rust
ledoyen/sql-collector
/src/metric/template.rs
UTF-8
3,083
3.40625
3
[ "Apache-2.0" ]
permissive
extern crate regex; use std::collections::HashMap; lazy_static! { static ref PATTERN_REGEX : regex::Regex = regex::Regex::new(r"\{([^\}]+)\}").unwrap(); } pub struct Template { raw: String, pub placeholders: Vec<String>, } impl Template { pub fn new<T: AsRef<str>>(name: T) -> Template { let ...
true
8d17c710d0bea4b86c0e72e0d7f85748e5f64a24
Rust
sshyran/imx8-rust
/imx8mm/src/mub/bcr.rs
UTF-8
19,398
2.96875
3
[]
no_license
#[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::BCR { #[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
79dfa9909caac916cd0dc7458807a17ede4d0534
Rust
gregmalcolm/rust-game-of-life
/src/view/lib.rs
UTF-8
1,172
3.09375
3
[]
no_license
extern mod cells; use cells::Cells; pub struct View { width: int, height: int, cells: Cells } impl View { pub fn new() -> View { let mut cells = Cells::new(); cells.randomize(10); let view = View { width: 60, height: 30, cel...
true
f709430f3d610f7aef13fcbfdb923579c4aa791b
Rust
tylerlowrey/cast-mesh
/cast-mesh-client/src/routes/mod.rs
UTF-8
1,136
2.90625
3
[]
no_license
use crate::routes::types::ServerRegistration; use rocket::State; use rocket_contrib::json::Json; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; use std::sync::atomic::{AtomicBool, Ordering}; #[post("/register_server", format = "json", data = "<registration_json>")] pub fn register_server( registration_json...
true
bd5d0c114610bf0cd67abb1234c4241d3cc3259f
Rust
domain-independent-dp/didp-rs
/dypdl-heuristic-search/src/search_algorithm/best_first_search.rs
UTF-8
9,889
2.59375
3
[ "MIT", "Apache-2.0" ]
permissive
use super::data_structure::{exceed_bound, BfsNode, StateRegistry, SuccessorGenerator}; use super::rollout::get_solution_cost_and_suffix; use super::search::{Parameters, Search, SearchInput, Solution}; use super::util::{update_bound_if_better, update_solution, TimeKeeper}; use dypdl::{variable_type, Transition, Transiti...
true
47afc528d4be0b2c46c1fca7ffd2828670585904
Rust
David-OConnor/esb
/src/irq.rs
UTF-8
15,324
2.59375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::{ app::Addresses, payload::{EsbHeader, PayloadR, PayloadW}, peripherals::{EsbRadio, EsbTimer, Interrupt, RxPayloadState, NVIC}, Config, Error, RAMP_UP_TIME, }; use bbqueue::{ framed::{FrameConsumer, FrameProducer}, ArrayLength, }; use core::{ marker::PhantomData, sync::atomic:...
true
b8624173e2e60f5acc5a0045da0d89f0ebeecf1d
Rust
astrojhgu/scorus
/examples/test_leapfrog.rs
UTF-8
687
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate scorus; use scorus::linear_space::type_wrapper::LsVec; use scorus::mcmc::hmc::utils::leapfrog; fn h_q(q: &LsVec<f64, Vec<f64>>) -> LsVec<f64, Vec<f64>> { let x = q[0]; let y = q[1]; let r = (x.powi(2) + y.powi(2)).sqrt(); LsVec(vec![r.powi(-3) * x, r.powi(-3) * y]) } fn h_p(p: &LsVec<f64,...
true
4c41d90bf971619c2cc545f8b4c43dce369bda5f
Rust
billyrieger/contrail
/contrail-collections/src/linked_list.rs
UTF-8
17,426
3.40625
3
[ "MPL-2.0" ]
permissive
/* * This Source Code Form is subject to the terms of the Mozilla Public License, * v. 2.0. If a copy of the MPL was not distributed with this file, You can * obtain one at http://mozilla.org/MPL/2.0/. */ //! Linked lists. use contrail::{ mem::Bytes, storage::{Backtrackable, NonBacktrackable, StorageMode}...
true
cf826369ecdd050638ddd261a63a55bee4a89ec8
Rust
qalens/kata-stringcalculator
/src/stringcalc.rs
UTF-8
2,461
3.625
4
[]
no_license
pub fn add(numbers: & str) -> usize{ let mut dels :Vec<String>= vec![",".to_string()]; let mut x = numbers.clone(); let mut split=x.split('\n'); let mut sum = 0; let mut negatives : Vec<String>=vec![]; let mut index = 0; for line in split { if(line.starts_with("//") && index == 0){...
true
d2325bf3467c0bb4938b1ee0dcac4a91218286dc
Rust
rust-lang/regex
/regex-syntax/src/lib.rs
UTF-8
17,453
3.453125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unicode" ]
permissive
/*! This crate provides a robust regular expression parser. This crate defines two primary types: * [`Ast`](ast::Ast) is the abstract syntax of a regular expression. An abstract syntax corresponds to a *structured representation* of the concrete syntax of a regular expression, where the concrete syntax is the p...
true
71d096b12dee76d4b269dc11b6c69b20e9764a40
Rust
Lapz/tox
/parser/src/parser/expressions/ident.rs
UTF-8
1,484
2.671875
3
[ "MIT" ]
permissive
use syntax::T; use crate::parser::pratt::{Precedence, PrefixParser}; use crate::parser::{restrictions::Restrictions, Parser}; use crate::SyntaxKind::*; #[derive(Debug)] pub struct IdentParselet; impl PrefixParser for IdentParselet { fn parse(&self, parser: &mut Parser) { let c = parser.checkpoint(); ...
true
9e0267315c6859632fc4ab4c2e2ddf2f4ccbf073
Rust
caswang0117/2D-Game-Engine
/src/obstacle.rs
UTF-8
2,662
2.96875
3
[]
no_license
use crate::texture::Texture; use crate::tiles::*; use crate::types::{Rect, Rgba, Vec2f}; use std::rc::Rc; pub struct Obstacle { pub image: Option<Rc<Texture>>, pub frame: Option<Rect>, pub tile_id: Option<TileID>, pub rect: Option<Rect>, // on tilemap for collisions pub destroyed: bool, } impl Obs...
true
5e9b4f4be6684038533d92898749aeeb32c837ed
Rust
Snowlabs/lemonade
/src/bin/lemon.rs
UTF-8
9,204
2.8125
3
[ "MIT" ]
permissive
use std; use std::cell::RefCell; use std::str::FromStr; use regex::Regex; use lemonade::format::{FormatItem, Image, Text, BG, Color}; pub struct LemonParser { pub bg: Color, pub fg: Color, pub ol: Color, pub ul: Color, pub ol_size: f64, pub ul_size: f64, pub font_list: Vec<String>, re: ...
true
2861452ed1708aa38c8b34d480dfe74f804335e4
Rust
bollo35/cryptopals
/src/bin/p008.rs
UTF-8
1,001
3.25
3
[]
no_license
use std::fs::File; use std::io::Read; use std::collections::HashSet; fn main() { let mut f = File::open("8.txt").expect("Unable to open '8.txt'"); let mut contents = String::new(); f.read_to_string(&mut contents).expect("Trouble reading '8.txt'"); let block_size = 2 * 16; // this is scaled for byte strings for l...
true
56108dd243f7f33f3cca0d24e10fb732b8d814fa
Rust
NyxCode/Ketamine
/parser/src/ast/literals.rs
UTF-8
2,017
2.625
3
[]
no_license
use crate::ast::{Ident, AST}; use crate::error::{ParseResult, ResultExt}; use crate::impl_into_enum; use crate::token_ext::TokenExt; use crate::{parse_list, Parse, Pos, Token}; use lexer::TokenValue; #[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[derive(Debug, Clone)] pub struct List(pub Vec<Pos<AST>>)...
true
e412327cdf4848f75cdd00da39bcc3b5a88fa5ff
Rust
markafarrell/gtp_rust
/src/gtp_v2/packet/messages/information_elements/msisdn.rs
UTF-8
8,964
3.34375
3
[ "MIT" ]
permissive
use super::{InformationElementTraits, InformationElementType, LENGTH}; use std::convert::TryInto; use byteorder::{ByteOrder, NetworkEndian}; pub struct InformationElement { /* Bits |---------------------------------------------------------------| ...
true
60e75e07ba91c5a2df343865a1e0b6df06b1cd13
Rust
BrainiumLLC/gee
/src/size.rs
UTF-8
7,063
3.25
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::Vector; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign}; #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] /...
true