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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b58888257cbb2968e9b261d6c46327f04fd23b8e | Rust | SyStem-5/LSOC-NeutronCommunicator | /src/settings/mod.rs | UTF-8 | 4,392 | 3.046875 | 3 | [] | no_license | use std::{fs::File, io::prelude::Read, io::Error, io::ErrorKind, io::Write, path::Path};
use serde_json::from_str;
use crate::{APP_NAME, BASE_DIRECTORY};
pub mod encryption_certificates;
pub mod mqtt_connection;
pub mod update_components;
pub mod structs;
const SETTINGS_FILE: &str = "settings.json";
/**
* Checks ... | true |
3ebd8ecee4616e8bc09fbf6132ae43068938eab1 | Rust | fcard/multimethods.rs | /src/main.rs | UTF-8 | 3,302 | 2.546875 | 3 | [
"MIT"
] | permissive | #![feature(fn_traits)]
#![feature(specialization)]
#![feature(unboxed_closures)]
#![feature(box_syntax)]
#![feature(trait_alias)]
#![feature(decl_macro)]
#![feature(associated_type_defaults)]
#![feature(proc_macro_hygiene)]
#![allow(non_upper_case_globals)]
#![feature(test)]
extern crate test;
pub mod value;
pub use ... | true |
c4d2ec32705fbd55f1f819f5a6084178c40c9516 | Rust | hashedone/advent-of-code-2019-rust | /src/day5.rs | UTF-8 | 4,407 | 3.390625 | 3 | [
"MIT"
] | permissive | use async_std;
use async_std::prelude::*;
use async_std::stream::Stream;
#[derive(Debug)]
enum Op {
Add,
Mul,
Read,
Write,
JmpT,
JmpF,
Less,
Equal,
}
impl Op {
fn new(code: i64) -> Self {
match code % 100 {
1 => Self::Add,
2 => Self::Mul,
... | true |
1a1e0eeaf90bdf2ddcf684aa6cc1ccde0f59327f | Rust | mhowto/bolt-rust | /src/page.rs | UTF-8 | 12,800 | 2.546875 | 3 | [] | no_license | #![plugin(quickcheck_macros)]
use types::pgid_t;
use std::mem;
use std::slice;
use std::fmt;
use meta::Meta;
use std::sync::{Once, ONCE_INIT};
use std::ptr;
pub const MAX_PAGE_SIZE: usize = 0x7FFFFFF;
pub const MAX_ALLOC_SIZE: usize = 0x7FFFFFFF;
pub const BRANCH_PAGE_FLAG: u16 = 0x01;
pub const LEAF_PAGE_FLAG: u16... | true |
3c8c22505267ccb64e70a7de2d20a005fbb17f38 | Rust | ZhongliGao/menmos | /crates/menmos-apikit/src/payload.rs | UTF-8 | 720 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | //! Useful prefabricated payloads.
use serde::{Deserialize, Serialize};
/// Standard message response.
///
/// Use when returning a single piece of unstructured information from your warp route. (e.g. "Upload Complete")
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct MessageRe... | true |
fb5780fed2994def3389f69dd78c530df07e048b | Rust | rrichardson/lout | /src/gelf.rs | UTF-8 | 19,689 | 2.6875 | 3 | [] | no_license |
use std::mem;
use std::slice;
use std::cmp::min;
use std::ptr;
use std::sync::Arc;
use std::time::Instant;
use std::io::{self, Read, Write, ErrorKind, BufReader};
use flate2::read::GzDecoder;
use flate2::write::{GzEncoder};
use flate2::Compression;
use std::collections::HashMap;
use serde_json::value::Value as JValue;... | true |
5775579709b6bbf1c4a177c0dbc3f8495fb6cdf7 | Rust | ReviveChang/leetcode-rust | /src/n_0746.rs | UTF-8 | 828 | 3.3125 | 3 | [] | no_license | pub struct Solution;
impl Solution {
pub fn min_cost_climbing_stairs(cost: Vec<i32>) -> i32 {
let mut dp = vec![0; cost.len() + 1];
let mut index = 2;
while index != dp.len() {
let first = dp[index - 2] + cost[index - 2];
let second = dp[index - 1] + cost[index - 1]... | true |
2ceac6d903d7b9d1eb4f4b88d6eda83acddbeb01 | Rust | jTitor/leek2 | /src/open-source/engine/modules/src/input/controller_components/keyfield_layout.rs | UTF-8 | 641 | 3.015625 | 3 | [] | no_license | use std::collections::HashMap;
use input::InputError;
use input::{CharacterCode, KeyCode, KeyfieldLayoutType};
pub struct KeyfieldLayout {
pub layout_type: KeyfieldLayoutType,
pub characters_to_keys: HashMap<CharacterCode, KeyCode>
}
impl KeyfieldLayout {
pub fn has_character_code(&self, character: CharacterCode) ... | true |
5e71faf8bbed96ec0bcde6b1d4ad70d6169b3969 | Rust | unity-haiwei/test | /dashboard/src/logic/message.rs | UTF-8 | 2,873 | 2.71875 | 3 | [] | no_license | use core::ops::Add;
use bson::Document;
use chrono::{DateTime, UTC};
use chrono::duration::Duration;
use config;
use utils;
use db::{self, DBTrait};
use Runtime;
use super::LogicTrait;
pub struct Message<'a> {
runtime: &'a Runtime,
db: db::Message,
users: Vec<Document>,
}
impl<'a> Message<'a> {
fn ... | true |
186108169585e7b978c5d96ac779fa65d518a250 | Rust | samlet/bluecc | /common/src/tests/name_tests.rs | UTF-8 | 1,502 | 3.25 | 3 | [] | no_license | use inflector::cases::camelcase::to_camel_case;
use inflector::cases::snakecase::to_snake_case;
#[test]
fn camelcase_works() {
let mock_string: &str = "FOO_BAR";
let expected_string: String = "fooBar".to_string();
let asserted_string: String = to_camel_case(mock_string);
assert!(asserted_string == expe... | true |
797f11d3a114126ea92e2f8979a9097eafecbba0 | Rust | klaxit/heroku_rs | /src/macros/mod.rs | UTF-8 | 1,241 | 3.078125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #[macro_export]
macro_rules! heroku_env {
($($element: expr => $value: expr),* $(,)?) => {{
const SIZE: usize = ($crate::count![@COUNT; $($element),*]);
#[allow(unused_mut)]
let mut vs = ::std::collections::HashMap::with_capacity(SIZE);
$(vs.insert($element, $value);)*
vs
... | true |
2116c698f97a7a3aad7be7a7366ac68f06de7a9d | Rust | dkeehl/chunfen | /src/bin/client.rs | UTF-8 | 2,610 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::net::{IpAddr, ToSocketAddrs};
fn main() {
let args: Vec<_> = std::env::args().collect();
let program = &args[0];
let mut opts = getopts::Options::new();
opts.reqopt("s", "server", "Remote server address", "IP:PORT")
.reqopt("k", "key", "Secret key for connect", "KEY")
.optopt(... | true |
42e2c79b0508a950a7b5964cdb7251583749d7ff | Rust | motoras/rust-algos | /euler/e_81/src/main.rs | UTF-8 | 1,273 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::cmp::min;
use std::fs::File;
use std::io::{BufRead, BufReader};
const LEN: usize = 80;
fn main() {
let mut input = [[0u32; LEN]; LEN];
// input[0] =[131,673,234,103,18];
// input[1] =[201,96,342,965,150];
// input[2] =[630,803,746,422,111];
// input[3] =[537,699,497,121,956];
// input... | true |
7483e12b2681061f65aa5b27e0b2086c2b800d93 | Rust | 604384120/kbsqpc | /src/rust/components/icon.rs | UTF-8 | 1,876 | 2.875 | 3 | [] | no_license | use std::convert::TryInto;
use stdweb::web::Node;
use stdweb::{js, Value};
use yew::prelude::*;
use yew::Callback;
pub enum Msg {
OnClick(Value),
}
pub struct Icon {
link: ComponentLink<Self>,
node: Node,
props: Props,
}
#[derive(Clone, PartialEq, Properties)]
pub struct Props {
#[prop_or_default... | true |
4ba9e09491a143440d7084c4d21321301ad6f34f | Rust | prisma/prisma-engines | /query-engine/schema/src/build/mutations/create_many.rs | UTF-8 | 3,602 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
use crate::{Identifier, IdentifierType, InputField, InputType, OutputField, OutputType, QueryInfo, QueryTag};
use constants::*;
use input_types::{fields::data_input_mapper::*, list_union_type};
use output_types::objects;
use prisma_models::{Model, RelationFieldRef};
use psl::datamodel_connector::Connector... | true |
4d1bd90dbb0bc9d1e0fd3fec1c22e80c9adefe2c | Rust | benp44/quick-size | /src/printer.rs | UTF-8 | 7,036 | 2.828125 | 3 | [] | no_license | use super::directory_entry::DirectoryEntry;
use super::print_entry::PrintEntry;
use colored::*;
use humansize::file_size_opts::{FileSizeOpts, FixedAt, Kilo};
use humansize::FileSize;
use sorted_list::SortedList;
use std::cmp;
use std::io;
use std::vec::Vec;
use term_size;
const TOTAL_NAME: &str = ".";
pub fn print_di... | true |
1e006b28ccce41eb9580311ff92bc4392ab0e779 | Rust | feenkcom/libskia | /libskia/src/image_filters.rs | UTF-8 | 3,452 | 2.5625 | 3 | [
"MIT"
] | permissive | use skia_safe::image_filters::{blur, drop_shadow, drop_shadow_only, image};
use skia_safe::{scalar, Color, Image, ImageFilter, Rect, SamplingOptions, TileMode, Vector};
use value_box::{ValueBox, ValueBoxPointer};
#[no_mangle]
pub fn skia_image_filter_blur(
sigma_x: scalar,
sigma_y: scalar,
tile_mode: TileM... | true |
29293b579087f2c540de10470a5f1d09a0d435e3 | Rust | nervosnetwork/merkle-mountain-range | /src/mmr_store.rs | UTF-8 | 1,692 | 2.921875 | 3 | [] | no_license | use crate::{vec::Vec, Result};
#[derive(Default)]
pub struct MMRBatch<Elem, Store> {
memory_batch: Vec<(u64, Vec<Elem>)>,
store: Store,
}
impl<Elem, Store> MMRBatch<Elem, Store> {
pub fn new(store: Store) -> Self {
MMRBatch {
memory_batch: Vec::new(),
store,
}
}... | true |
8713c3e7820f1b87d0fc6df4fa274b9b211d2874 | Rust | crescentrose/sunshine | /src/sunshine/locators.rs | UTF-8 | 6,459 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(target_os = "macos")]
extern crate corelocation_rs;
#[cfg(target_os = "macos")]
use corelocation_rs::Locator;
use super::errors::*;
use super::name_cache::LocationCache;
use super::name_cache::LocationCacher;
use super::Result;
use reqwest::Url;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
#[... | true |
885479c93ce5bce2990245fa7bd6efc814fbce43 | Rust | rarescosma/eldiro | /crates/eldiro/src/binding_def.rs | UTF-8 | 2,061 | 3.46875 | 3 | [
"MIT"
] | permissive | use crate::env::Env;
use crate::expr::Expr;
use crate::utils;
use crate::val::Val;
#[derive(Debug, PartialEq, Clone)]
pub(crate) struct BindingDef {
pub(crate) name: String,
pub(crate) val: Expr,
}
impl BindingDef {
pub(crate) fn new(s: &str) -> Result<(&str, Self), String> {
let s = utils::tag("l... | true |
0da5896e7cd870583471dbb1c98323cc585e2509 | Rust | nrc/proc-macro-rules | /macros/src/lib.rs | UTF-8 | 3,832 | 2.515625 | 3 | [] | no_license | #![recursion_limit = "256"]
extern crate proc_macro;
extern crate proc_macro2;
extern crate quote;
extern crate syn;
use proc_macro::TokenStream;
use quote::ToTokens;
use syn::parse_macro_input;
mod ast;
mod expand;
mod parse;
#[proc_macro]
pub fn rules(input: TokenStream) -> TokenStream {
parse_macro_input!(in... | true |
e807669d8080cfa9e7a81579b57298d34130beb9 | Rust | kencruz/advent-of-code | /2018/rust/src/day02.rs | UTF-8 | 2,227 | 3.375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
#[allow(dead_code)]
pub fn star_one(input: &str) -> u32 {
let mut twice = 0;
let mut thrice = 0;
for line in input.lines() {
let mut uniques: HashMap<char, u32> = HashMap::new();
for el in line.chars() {
let increment = uniques.entry(el).or_insert(... | true |
d9d3825f24c9791c2e7c2957a9394cbde4a137f6 | Rust | johnshift/rust-ds | /array/src/exercise.rs | UTF-8 | 674 | 3.984375 | 4 | [] | no_license | // Exercise 1:
// - given two arrays, merge both arrays into one that is sorted
fn array_exercise1<T: Ord>(a1: Vec<T>, a2: Vec<T>) -> Vec<T> {
let mut result: Vec<T> = a1.into_iter().chain(a2.into_iter()).collect();
result.sort();
result
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn array_exercise... | true |
b3fc21ddd938eb219b4c4349835d0bb2bc46bebf | Rust | danielgallagher0/bluetooth-hci | /src/bitflag_array.rs | UTF-8 | 7,078 | 3.09375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Re-export libcore using an alias so that the macros can work without
// requiring `extern crate core` downstream.
#[doc(hidden)]
pub extern crate core as _core;
/// Implements an arbitrary-length bitfield. The implementation and interface is similar to and
/// derived from [bitflags](https://crates.io/crates/bitfl... | true |
40f3339c787735ee2f735dc19ff41ac25fe4bdac | Rust | haleywm/Project-Euler | /src/bin/24.rs | UTF-8 | 1,126 | 3.359375 | 3 | [] | no_license | use std::cmp::min;
fn main() {
const MAX: u64 = 9;
const GET: u64 = 1_000_000;
let vals: Vec<u64> = (0..=MAX).collect();
let lehmer = num_to_lehmer(GET - 1, MAX as usize + 1);
let result = decode_lehmer(vals, lehmer);
for num in result {
print!("{}", num);
}
println!();
}
fn n... | true |
ca32c0bba3aedd50566fcb45485a169a5a6ceee5 | Rust | Henning-K/printpdf | /src/types/plugins/graphics/two_dimensional/point.rs | UTF-8 | 1,145 | 3.625 | 4 | [
"MIT"
] | permissive | #[derive(Debug, Copy, Clone)]
pub struct Point {
/// x position from the bottom left corner in pt
pub x: f64,
/// y position from the bottom left corner in pt
pub y: f64
}
impl Point {
/// Create a new point.
/// **WARNING: The reference point for a point is the bottom left corner, not the top... | true |
4833d20c196e30b27d6d6ad4334759fe690970c8 | Rust | mattwoodyard/appgen | /src/view_gen.rs | UTF-8 | 8,997 | 2.921875 | 3 | [] | no_license |
use std::collections::HashMap;
use schema_spec::*;
macro_rules! hashmap {
($( $key: expr => $val: expr ),*) => {{
let mut map = ::std::collections::HashMap::new();
$( map.insert($key, $val); )*
map
}}
}
#[derive(Debug)]
pub enum IKind {
Defaulted(String),
Named(String),
... | true |
a78bb7acfcee1b9fd54dce31bc5f1fbe62babe86 | Rust | thepowersgang/stack_dst-rs | /tests/fifo.rs | UTF-8 | 3,657 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | extern crate stack_dst;
type DstFifo<T> = stack_dst::Fifo<T, ::stack_dst::buffers::Ptr8>;
#[test]
// A trivial check that ensures that methods are correctly called
fn trivial_type() {
let mut val = DstFifo::<dyn PartialEq<u32>>::new();
val.push_back_stable(1234, |p| p).unwrap();
val.push_back_stable(1233,... | true |
30bdeca1481a2f9bbee6cc518a85e59232940549 | Rust | iFaceless/gic | /src/command.rs | UTF-8 | 3,839 | 2.90625 | 3 | [
"MIT"
] | permissive | use clap::{App, Arg, ArgMatches};
use crate::gitmoji::{Gitmoji, GitmojiConfig};
#[derive(Debug)]
pub struct CommandOption<'a> {
pub scope: Vec<String>,
pub jira: Vec<String>,
pub issue: Vec<String>,
pub message: String,
pub amend: bool,
pub gitmoji: Option<&'a Gitmoji>,
}
pub struct CommandAp... | true |
b06e763584242fd8fd6f8a39784474424dafebce | Rust | skanev/playground | /advent-of-code/2021/day19/src/main.rs | UTF-8 | 6,567 | 2.796875 | 3 | [] | no_license | use std::{
collections::{HashSet, VecDeque},
fs,
ops::{Mul, Sub},
};
type Number = i16;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[repr(transparent)]
struct Matrix([[Number; 4]; 4]);
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[repr(transparent)]
struct Point([Number; 4]);
struct Varia... | true |
fd37556fdae2b4e507a510fc2ce107f4da0e2bae | Rust | kmeisthax/retrogram | /src/project/program.rs | UTF-8 | 7,267 | 3.28125 | 3 | [] | no_license | //! Program identifier
use crate::arch::ArchName;
use crate::asm::AssemblerName;
use crate::platform::PlatformName;
use clap::{App, Arg, ArgMatches, ArgSettings};
use relative_path::{RelativePath, RelativePathBuf};
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use thiserror::Error;
/// Errors yielded fr... | true |
b45bc3d6d81c37d09b0fe59931d5ef9da64c62aa | Rust | johshoff/mandel | /src/main.rs | UTF-8 | 13,506 | 2.640625 | 3 | [] | no_license | extern crate gl;
extern crate glfw;
extern crate time;
extern crate point;
use std::sync::mpsc::channel;
use std::thread::spawn;
use std::mem;
use std::ptr;
use std::ffi::CString;
use std::fs::File;
use std::io::Read;
use std::fmt::{ Display, Formatter };
use std::fmt;
use std::cmp::{Eq, PartialEq};
use gl::types::*;... | true |
40105b583568bd27f189fe2b433d77a0e885fd31 | Rust | jgagnon1/advent-rust-2018 | /src/day5/mod.rs | UTF-8 | 1,183 | 3.125 | 3 | [
"MIT"
] | permissive | use std::io::{self, BufRead};
// Disclaimer: Tried to leave Itertools aside for this one and take a more rusty approach ;)
pub fn solve() -> Result<(), io::Error> {
let stdin = io::stdin();
let data = stdin
.lock()
.lines()
.filter_map(|line| line.ok())
.next()
.unwrap()... | true |
098dab421a4dea93504ace828560d9c7216a37cc | Rust | samrat/rusl | /src/ast.rs | UTF-8 | 16,316 | 3.1875 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use util::get_unique_varname;
#[derive(Debug, PartialEq, Clone)]
pub enum CC {
// condition codes
E, L, LE, G, GE,
}
#[derive(Debug, Clone)]
pub enum Ast {
Symbol(Rc<String>),
Number(i64),
Bool(bool),
List(Vec<Ast>),
FuncName(Rc<S... | true |
282f3ec7eaed98ba8db297748465d3024ab71358 | Rust | JayTee42/rusty-mimasim | /src/microcycle/execute.rs | UTF-8 | 5,670 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::types::{*, Registers as Regs};
use crate::bus::Xfer as BusXfer;
use crate::unit::{ALUOperation::*, MemoryAccess::*};
use super::descriptor::Descriptor;
// Helper for a new, empty descriptor:
fn empty_desc() -> Descriptor
{
Descriptor::empty()
}
// Return the microcycle descriptor for the microcycle in [6,... | true |
7ad9817d071b7f3ab4a1d6a425d19ec314f6d722 | Rust | southpawgeek/perlweeklychallenge-club | /challenge-105/roger-bell-west/rust/ch-2.rs | UTF-8 | 654 | 3.046875 | 3 | [] | no_license | use regex::Regex;
// Cargo.toml needs:
// [dependencies]
// regex = "1"
#[test]
fn test_ex1() {
assert_eq!(ng("Katie"),"Katie, Katie, bo-batie\nBonana-fanna fo-fatie\nFee fi mo-matie\nKatie!");
}
#[test]
fn test_ex2() {
assert_eq!(ng("Anna"),"Anna, Anna, bo-banna\nBonana-fanna fo-fanna\nFee fi mo-manna\nAnna... | true |
81a4ba5a3a76789ad8de23a7424f41d544a2c128 | Rust | MHamill98/tictactoe | /src/main.rs | UTF-8 | 4,489 | 3.171875 | 3 | [] | no_license | use permutohedron;
use std::io;
fn main() {
println!("Welcome to Tic, Tac, Toe!");
println!("Player 1, please choose X or O.");
let mut player = String::new();
io::stdin().read_line(&mut player).unwrap();
let mut board = Board::new(player.trim());
board.print();
while board.free_spaces()... | true |
aed9e64810ddbc6b76a6adb343df9dcbcd5d2bda | Rust | nymtech/nym | /common/cosmwasm-smart-contracts/mixnet-contract/src/gateway.rs | UTF-8 | 8,415 | 2.578125 | 3 | [
"CC0-1.0",
"Apache-2.0"
] | permissive | // Copyright 2021-2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use crate::{IdentityKey, SphinxKey};
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Coin};
use std::cmp::Ordering;
use std::fmt::Display;
/// Information provided by the node operator during bonding that... | true |
54556e1e4b378fca6ebce5985f30db110683667a | Rust | Wkkkkk/hash_rings | /src/consistent.rs | UTF-8 | 4,305 | 3.296875 | 3 | [] | no_license | use crate::util;
use std::collections::hash_map::RandomState;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::hash::{BuildHasher, Hash};
use std::iter::Iterator;
use std::vec::Vec;
/// A hashing ring implemented using consistent hashing.
///
/// Consistent hashing is based on mapping each node to a pseudo... | true |
34d16a48925ed74b024458d31dfe04b7e0235500 | Rust | procuteboy/inko | /vm/tests/instructions/literals.rs | UTF-8 | 554 | 2.5625 | 3 | [] | no_license | use libinko::object_pointer::ObjectPointer;
use libinko::vm::instruction::InstructionType;
use libinko::vm::test::*;
#[test]
fn test_set_literal() {
let (machine, mut block, process) = setup();
block.code.instructions =
vec![new_instruction(InstructionType::SetLiteral, vec![0, 0]),
new_in... | true |
7af027c6b0e41fb64fbebc7d76621935a344a147 | Rust | me020523/rust-playground | /mutability/src/main.rs | UTF-8 | 834 | 3.734375 | 4 | [] | no_license | fn main() {
left_value();
right_value();
scalar_value();
}
fn left_value() {
let x = 5;
//x = 6; //compiler panic
let mut y = 5;
println!("x is {}, y is {}", x, y);
y = 6;
println!("new y is {}", y)
}
fn right_value() {
struct Point {
pub a : i8,
pub b : i8
... | true |
15b9cc4de2a61a6aa63bc41d556d208e72fa08c8 | Rust | gzbakku/gzbdb | /gmessage/src/v1/client/auth.rs | UTF-8 | 7,061 | 2.578125 | 3 | [] | no_license |
use crate::Error;
use crate::common::Error;
use crate::crypt;
pub enum AuthToken{
Session(SessionAuth),
Key(KeyAuth)
}
use openssl::pkey::{Public,Private};
use openssl::pkey::PKey;
#[allow(dead_code)]
impl AuthToken{
pub fn session(id:String,password:String) -> AuthToken{
AuthToken::Session(Ses... | true |
274efb97becf5b992595535e9abf840461b9c8c0 | Rust | QuilonQuest/ProximaNet | /ext-eth-bridge-apps/aurora-engine/src/prelude.rs | UTF-8 | 2,516 | 3 | 3 | [
"CC0-1.0"
] | permissive | #[cfg(not(feature = "std"))]
pub use alloc::{
borrow::ToOwned,
borrow::{Cow, Cow::*},
boxed::Box,
collections::BTreeMap as HashMap,
collections::BTreeMap,
fmt, format, str,
string::String,
string::ToString,
vec,
vec::Vec,
};
#[cfg(not(feature = "std"))]
pub use core::{
cmp::O... | true |
9ba4297c21a90fad09f9a61fec81b3f62e1bd2cd | Rust | therealprof/stm32f042 | /src/cec/cfgr/mod.rs | UTF-8 | 11,006 | 2.859375 | 3 | [
"BSD-3-Clause",
"0BSD"
] | 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::CFGR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... | true |
fde71d9d480cecc2e303cb3f289b03e849e4793d | Rust | tarasglek/jsonbench | /rust.rs | UTF-8 | 1,112 | 2.84375 | 3 | [] | no_license | extern mod extra;
fn main() {
let i = std::io::stdin();
let t1 = extra::time::get_time();
let mut bytes_read = 0;
while !i.eof() {
let line = i.read_line();
let json = extra::json::from_str(line);
if line.len() != 0 {
bytes_read += line.len();
match (jso... | true |
8857f0555869f12c191a274494a590269214b25d | Rust | caibirdme/leetcode_rust | /src/prob_394.rs | UTF-8 | 3,980 | 3.203125 | 3 | [
"MIT"
] | permissive | impl Solution {
pub fn decode_string(s: String) -> String {
let mut ans = vec![];
let mut repeat = vec![];
let mut q = vec![];
let mut i = 0;
let bs = s.as_bytes();
while i < bs.len() {
match bs[i] {
b'0'...b'9'=> {
let ... | true |
c126bd5152df0fb10e36aeec2327fff3ad1a31f9 | Rust | eira-fransham/flow-field-pathfinding | /src/lib.rs | UTF-8 | 5,936 | 2.734375 | 3 | [] | no_license | #![feature(nll)]
extern crate petgraph;
use std::collections::HashMap;
use petgraph::{Graph, EdgeType};
use petgraph::graph::NodeIndex;
use petgraph::visit::EdgeRef;
pub struct PathIterator<'a> {
current: Option<NodeIndex>,
mesh: &'a NavMesh,
}
impl<'a> Iterator for PathIterator<'a> {
type Item = NodeIn... | true |
bcae5b2e3bd0ac6c099dde12e7e4984e501fe230 | Rust | Cu3PO42/save3ds | /libsave3ds/src/random_access_file.rs | UTF-8 | 2,238 | 2.84375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::error::*;
use byte_struct::*;
use std::borrow::Borrow;
pub trait RandomAccessFile {
fn read(&self, pos: usize, buf: &mut [u8]) -> Result<(), Error>;
fn write(&self, pos: usize, buf: &[u8]) -> Result<(), Error>;
fn len(&self) -> usize;
fn commit(&self) -> Result<(), Error>;
}
pub fn read_str... | true |
6bfbc7df2724b3465e4424cf58f241a589061570 | Rust | ebkalderon/sink-futures-example | /src/bin/old.rs | UTF-8 | 1,463 | 2.640625 | 3 | [] | no_license | use futures_old::future::{self, Future};
use futures_old::sink::Sink;
use futures_old::stream::{self, Stream};
use futures_old::sync::mpsc::{self, Receiver, Sender};
use futures_old::Poll;
#[allow(dead_code)]
type MyReceiver = Receiver<Result<String, ()>>;
type MySender = Sender<Result<String, ()>>;
pub struct JobFut... | true |
b094fe16ed3a827d8ab73ea9cea233d4ba3bf745 | Rust | ebelliveau/mars-raw-utils | /src/m20/zcam.rs | UTF-8 | 2,004 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::{
vprintln,
rgbimage,
enums,
path,
decompanding,
constants,
util
};
pub fn process_file(input_file:&str, red_scalar:f32, green_scalar:f32, blue_scalar:f32, no_ilt:bool, only_new:bool) {
let out_file = util::append_file_name(input_file, constants::OUTPUT_FILENAME_APPEND);
... | true |
1ea16d93641d6d9bd52d1f4478cc7a5b0adfc596 | Rust | luketchang/Rust-HTTP-Server | /src/http/query_string.rs | UTF-8 | 2,304 | 4 | 4 | [] | no_license | use std::collections::HashMap;
use std::convert::From;
/* Struct: QueryString
* ___________________
* - stored as a hashmap to account for different pieces of query string
* - mapping from buf string to Value type (either single buf string or array of buf strings)
* - example: a=1&b=2&c&d=&e&d=4...
*/
#[derive... | true |
57ed3f006de647b6341600eefb68c34758532ef2 | Rust | ddboline/weather_util_rust | /src/timezone.rs | UTF-8 | 1,097 | 3.203125 | 3 | [
"MIT"
] | permissive | use nutype::nutype;
use time::UtcOffset;
/// Direction in degrees
#[nutype(validate(min=-86400, max=86400))]
#[derive(*, Serialize, Deserialize, Display, Into)]
pub struct TimeZone(i32);
impl Default for TimeZone {
fn default() -> Self {
Self::new(0).unwrap()
}
}
impl From<TimeZone> for UtcOffset {
... | true |
521b3f26efb5617b8f37a6b90ce959c03e62e5ef | Rust | not-much-io/serverd | /monitoring-service/src/lib.rs | UTF-8 | 7,427 | 2.640625 | 3 | [] | no_license | use std::{
collections::HashMap,
hash::Hash,
sync::Arc,
thread::{sleep, spawn, JoinHandle, Result as ThreadResult},
time::Duration,
};
use internal_prelude::library_prelude::*;
// A significant event that should be reacted to with an action (or multiple)
#[rustfmt::skip]
pub trait Event: Eq
+ ... | true |
735af7652916aa7e77fdc8f10f7c1a8bef5c1619 | Rust | lpartan/zotero-to-obsidian | /src/resource_types.rs | UTF-8 | 23,280 | 2.796875 | 3 | [] | no_license | use super::json_parser::{Creator, Item, Note, Tag};
use dissolve::strip_html_tags;
use std::fmt::{self, Display};
use std::fs::File;
use std::io::Read;
const TEMPLATE_PATH:&str = "Meta/Templates/Resource";
pub trait ResourceList<T> {
fn add(&mut self, resource: T) -> ();
fn print(&self) -> String;
}
pub trai... | true |
cfc8d78fd7bf49ae0bf3b390c5a498b2cd763ea4 | Rust | Vicfred/RustPython | /src/shell.rs | UTF-8 | 7,916 | 2.625 | 3 | [
"MIT"
] | permissive | #[cfg(not(target_os = "wasi"))]
mod rustyline_helper;
use rustpython_compiler::{compile, error::CompileError, error::CompileErrorType};
use rustpython_parser::error::ParseErrorType;
use rustpython_vm::{
obj::objtype,
print_exception,
pyobject::{ItemProtocol, PyObjectRef, PyResult},
scope::Scope,
Vi... | true |
1a9f0d421f917f2517fc5c76221869804d822958 | Rust | momotaro98/rust-codes-for-learning | /rust-official-guide/chap9-error-handling/src/main.rs | UTF-8 | 2,096 | 3.984375 | 4 | [] | no_license |
use std::fs::File;
use std::io::ErrorKind;
fn main() {
let f = File::open("hello.txt");
//// 下記のList4とList5は等価な処理
//// やりたいこと → ファイルをOpen, なければ新規にファイル作成
// List 4 matchを使う場合
let f = match f {
Ok(file) => file,
Err(error) => match error.kind() {
ErrorKind::NotFound => ... | true |
21b7c9ea4af31b526d7175299526ae06b015cfe0 | Rust | serdaraltin/Epic-Asset-Manager | /src/models/category_data.rs | UTF-8 | 3,456 | 2.953125 | 3 | [
"MIT"
] | permissive | use glib::ObjectExt;
use gtk4::{glib, subclass::prelude::*};
mod imp {
use super::*;
use gtk4::glib::ToValue;
use std::cell::RefCell;
#[derive(Debug, Default)]
pub struct CategoryData {
filter: RefCell<Option<String>>,
name: RefCell<Option<String>>,
}
// Basic declaration ... | true |
8c963cd7c431f1c4e3c50d509c2c4f9ff0477a87 | Rust | dainslef/RustPractice | /src/leetcode/q81_search_in_rotated_sorted_array_ii.rs | UTF-8 | 2,613 | 3.609375 | 4 | [
"BSD-3-Clause"
] | permissive | /**
* 81. Search in Rotated Sorted Array II
* https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
*
* Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
*
* (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).
*
* You are given a target value to search. ... | true |
4048c6f4b1f1f6d521eecda1ee9eaa40aaad439c | Rust | gbutler69/rust-exercism | /sieve/src/lib.rs | UTF-8 | 1,477 | 3.140625 | 3 | [] | no_license | pub fn primes_up_to(upper_bound: u64) -> Vec<u64> {
eliminate_composites_using_sieve_of_eratosthenes_up_to(upper_bound)
.into_iter()
.enumerate()
.filter_map(only_if_prime)
.collect()
}
fn eliminate_composites_using_sieve_of_eratosthenes_up_to(upper_bound: u64) -> Vec<bool> {
le... | true |
234d3afd2d038f1bdd731d84be47fed6fea2981d | Rust | ytakasugi/workspace | /Rust_workspace/rust_basics/basic/chapter05/chapter0513/src/main.rs | UTF-8 | 2,694 | 3.84375 | 4 | [] | no_license | struct Polygon {
vertexes: Vec<(i32, i32)>, // 頂点の座標
#[allow(dead_code)]
stroke_width: u8, // 輪郭の太さ
fill: (u8, u8, u8), // 塗りつぶしのRGB色
}
// フィールド名と同じ名前の関数引数やローカル変数がある時は以下のような
// 省略形も使える(Rust 1.17以降)
fn new_polygon(vertexes: Vec<(i32, i32)>) -> Polygon {
let stroke_width = 1;
l... | true |
53b5ea2b70ea33b7bc5e41941592b16f88a35087 | Rust | orndorffgrant/boa | /boa/src/syntax/parser/tests.rs | UTF-8 | 9,201 | 3.171875 | 3 | [
"MIT",
"Unlicense"
] | permissive | //! Tests for the parser.
use super::Parser;
use crate::syntax::ast::{
node::{
field::GetConstField, ArrowFunctionDecl, Assign, BinOp, Call, Declaration, DeclarationList,
FormalParameter, FunctionDecl, Identifier, If, New, Node, Object, PropertyDefinition,
Return, StatementList, UnaryOp,
... | true |
7425e8e056e499ab0f1fc9ecc7e1be2985f97a79 | Rust | majiru/rtr | /src/main.rs | UTF-8 | 2,016 | 3.015625 | 3 | [
"MIT"
] | permissive | use regex::Regex;
use rss::{Channel, Item};
use serde_derive::{Deserialize, Serialize};
use std::env;
use std::fs;
use std::iter::Iterator;
#[derive(Serialize, Deserialize, Debug)]
struct Filter {
key: String,
regexp: String,
}
impl Filter {
fn apply(&self, items: Vec<Item>) -> Vec<Item> {
let re = Regex::new(&s... | true |
85f74a77bf1fe21d52107b194ec751144e37869d | Rust | NereusLee/canvas | /src/lib.rs | UTF-8 | 10,049 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | extern crate websocket;
mod http_server;
mod api;
use std::net::SocketAddr;
use std::iter::Iterator;
use std::sync::mpsc::{self, Receiver};
use std::thread;
use websocket::sync::Server;
use websocket::OwnedMessage;
pub use api::*;
#[allow(non_snake_case)]
impl Canvas for WebCanvas {
fn clearRect(&mut self, x: f... | true |
f78295c3f9e8ac008676e5701c3a1b687549f737 | Rust | ChMarP/mogwai | /examples/sandbox/src/elm_button.rs | UTF-8 | 1,169 | 3 | 3 | [] | no_license | use mogwai::prelude::*;
pub struct Button {
pub clicks: i32,
}
#[derive(Clone)]
pub enum ButtonIn {
Click,
}
#[derive(Clone)]
pub enum ButtonOut {
Clicks(i32),
}
impl Component for Button {
type ModelMsg = ButtonIn;
type ViewMsg = ButtonOut;
type DomNode = HtmlElement;
fn update(
... | true |
6056fab5d290fd21e570c7d7eee68d7ed87124bf | Rust | Chris--B/advent-of-code | /2021/src/day12.rs | UTF-8 | 4,842 | 3.09375 | 3 | [] | no_license | use aoc_runner_derive::{aoc, aoc_generator};
use std::collections::HashMap;
#[aoc_generator(day12)]
pub fn parse_input(input: &str) -> HashMap<String, Vec<String>> {
let mut graph = HashMap::new();
for line in input.lines() {
let mut iter = line.split('-');
let from = iter.next().unwrap();
... | true |
192605657993132ea9e059dcfcda60be2b213721 | Rust | llde/rCrawly | /src/API/executors.rs | UTF-8 | 2,468 | 3.1875 | 3 | [] | no_license | use std::sync::{Arc,Mutex,RwLock};
use std::collections::VecDeque;
use std::thread;
use API::Future;
enum STATUS{
RUNNING,
SHUTDOWN,
PAUSED,
}
pub enum ERRORS{
IS_SHUTDOWN
}
pub struct ThreadPoolExecutor<T>{
workers : Arc<Mutex<VecDeque<Arc<Future<T>>>>>,
status: Arc<Mutex<ST... | true |
8808acb74f0c3350a748f9bc12f1a397c33b5122 | Rust | xNul/SmolECS | /SmolCommon/src/join.rs | UTF-8 | 1,440 | 2.859375 | 3 | [] | no_license | use SmolCommonMacros::{impl_joinable, impl_joinable_multi};
pub trait Joinable<'w> {
type Target;
fn join(self) -> JoinIter<'w, Self::Target>;
}
pub struct JoinIter<'w, T>{
pub items: Box<Iterator<Item = (bool, Option<T>)> + 'w>,
}
impl<'w, T> Iterator for JoinIter<'w, T>{
type Item = T;
fn n... | true |
fde80f402361ca5044479d8fe8bff7dc871481e4 | Rust | charpercyr/chos | /kernel/src/sched/sync/sem.rs | UTF-8 | 2,398 | 2.640625 | 3 | [] | no_license | use chos_lib::sync::sem::TrySem;
use chos_lib::sync::{Sem, SpinSem, Spinlock};
use intrusive_collections::{intrusive_adapter, linked_list, UnsafeMut};
use crate::sched::{current_task_arc, Task, TaskArc};
const TRIES: usize = 64;
struct WaitNode {
link: linked_list::AtomicLink,
count: usize,
task: Option<... | true |
8ce33cf003b96b98b0c123ad329e38d5bd713c97 | Rust | cjfuller/adventofcode2020 | /src/d5.rs | UTF-8 | 1,654 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::util;
fn parse_seat(seat_str: &str) -> (i32, i32) {
let row = seat_str
.chars()
.take(7)
.enumerate()
.fold(0, |acc, (i, curr)| {
acc + ((if curr == 'B' { 1 } else { 0 }) << (6 - i))
});
let col = seat_str
.chars()
.skip(7)
... | true |
4edbf79dc5471ee7f0e078b463ac11406e2e9ec2 | Rust | Kmeakin/SiMPL | /src/codegen/llvm.rs | UTF-8 | 14,673 | 2.578125 | 3 | [] | no_license | use super::closure::{Binop, CExpr, FreeVars, LetBinding, Lit, Param, Type};
use inkwell::{
builder::Builder,
context::Context,
module::Module,
types::{BasicType, BasicTypeEnum},
values::{AnyValue, BasicValue, BasicValueEnum, FunctionValue, PointerValue},
AddressSpace, FloatPredicate, IntPredicat... | true |
768ecc58354b0ecb92244acf3a4643e1e308ea40 | Rust | scholtzan/rdf-rs | /src/reader/rdf_parser.rs | UTF-8 | 308 | 2.640625 | 3 | [
"MIT"
] | permissive | use crate::graph::Graph;
use crate::Result;
/// Trait implemented by RDF parsers to generate a RDF graph from RDF syntax.
pub trait RdfParser {
/// Generates an RDF graph from a provided RDF syntax.
/// Returns an error if invalid RDF input is provided.
fn decode(&mut self) -> Result<Graph>;
}
| true |
ec706dd91d056f59c160f4f841cb8c4a05941ec2 | Rust | awslabs/aws-lambda-rust-runtime | /lambda-http/src/ext/extensions.rs | UTF-8 | 19,363 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | //! Extension methods for `http::Extensions` and `http::Request<T>` types
use aws_lambda_events::query_map::QueryMap;
use http::request::Parts;
use lambda_runtime::Context;
use crate::request::RequestContext;
/// ALB/API gateway pre-parsed http query string parameters
pub(crate) struct QueryStringParameters(pub(crat... | true |
9284f35e865ea6655791486a50bbab38b9db98e3 | Rust | dennisss/dacha | /pkg/math/src/geometry/quantized.rs | UTF-8 | 3,211 | 3.296875 | 3 | [
"Apache-2.0"
] | permissive | use core::ops::Deref;
use core::{cmp::Ordering, ops::Sub};
use crate::matrix::element::FloatElementType;
use crate::matrix::Vector2i64;
use crate::number::Cast;
use crate::number::Float;
use crate::{
matrix::{vec2f, Vector2, Vector2f},
rational::Rational,
};
const SCALE: f32 = 1000.0;
// /// Quantized vector... | true |
d9e78ad33ca80c15f802998b48e9d8fef17b1523 | Rust | p7g/nand2tetris-vm-translator | /src/parser.rs | UTF-8 | 911 | 3.03125 | 3 | [] | no_license | use super::token::{Token, TokenType};
use super::command::{Command};
pub fn parse<'a>(tokens: &'a Vec<Token<'a>>) -> Vec<Command<'a>> {
let mut commands = Vec::new();
let mut command: Option<Command> = None;
for token in tokens.iter() {
match token.type_ {
TokenType::Newline => {
if let Some(c... | true |
8181983fc306a2bd7c9932536e1602bc5f74d587 | Rust | SPERAXIO/ckb | /util/types/src/utilities/difficulty.rs | UTF-8 | 7,554 | 2.9375 | 3 | [
"MIT"
] | permissive | use numext_fixed_uint::prelude::UintConvert;
use numext_fixed_uint::{u512, U256, U512};
pub const DIFF_TWO: u32 = 0x2080_0000;
const ONE: U256 = U256::one();
// ONE << 256
const HSPACE: U512 = u512!("0x10000000000000000000000000000000000000000000000000000000000000000");
fn target_to_difficulty(target: &U256) -> U256... | true |
b75710fca85fb6758ed54a4d1082dd697fd1964e | Rust | kofmatsugen/sprite_studio | /src/traits/translate_animation.rs | UTF-8 | 1,071 | 2.59375 | 3 | [] | no_license | use crate::traits::animation_file::AnimationFile;
use amethyst::ecs::{Entity, SystemData};
pub trait TranslateAnimation<'s>: 'static + Send + Sync + AnimationFile {
type OptionalData: SystemData<'s>;
// アニメーション遷移
fn translate_animation(
_entity: Entity, // アニメーションを再生してるエンティティ
... | true |
cbfc8d245379a628614155a9c1831adfb74d3c22 | Rust | chromium/chromium | /third_party/rust/rstest/v0_17/crate/tests/resources/rstest/impl_param.rs | UTF-8 | 362 | 2.90625 | 3 | [
"GPL-1.0-or-later",
"MIT",
"LGPL-2.0-or-later",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | use rstest::*;
#[fixture]
fn fixture() -> String { "str".to_owned() }
#[rstest]
fn simple(fixture: impl AsRef<str>) {
assert_eq!(3, fixture.as_ref().len());
}
#[rstest(
expected, input,
case(4, String::from("ciao")),
case(3, "Foo")
)]
fn strlen_test(expected: usize, input: impl AsRef<str>) {
asse... | true |
d79588c01123f0131b55005db6bd4b1677bf56fc | Rust | the10thWiz/autoconfnet | /src/parse.rs | UTF-8 | 15,882 | 3.1875 | 3 | [] | no_license | use crate::file::File;
use crate::interface::*;
use crate::ip::*;
use std::collections::HashMap;
use std::ops::*;
use std::default::Default;
#[derive(Debug, Clone)]
enum Value {
Simple(String, bool),
Selected(String, Vec<String>, bool),
Range(isize, Range<isize>, bool),
IP(IPv4, bool),
Interface(If... | true |
88dc4c0e896b6575936d8a62b5ec5847d02424a1 | Rust | PeriodicLaw/MyFP | /src/context.rs | UTF-8 | 6,863 | 3.21875 | 3 | [] | no_license | use crate::ast::{Expr, Type};
use std::collections::{BTreeMap, BTreeSet};
use std::fmt::{Display, Formatter, Result};
#[derive(Debug, Clone)]
pub struct TypeContext {
pub free: BTreeSet<String>,
bounded: BTreeMap<String, Type>,
counter: i32,
}
impl TypeContext {
pub fn new() -> Self {
TypeContext {
free: BTr... | true |
79d33fbe2e721d553bb534e1479ded2bb0edc1dd | Rust | Aloso/tco | /src/lib.rs | UTF-8 | 3,432 | 2.671875 | 3 | [] | no_license | extern crate proc_macro;
use proc_macro::TokenStream;
use quote::{quote, format_ident};
use syn::{parse_macro_input, ItemFn, Ident, FnArg, ExprCall, Pat, Block, Expr};
use syn::visit_mut::{self, VisitMut};
use syn::{parse_quote};
use syn::spanned::Spanned;
struct TCO {
ident: Ident,
args: Vec<Ident>,
i: u... | true |
46dd746cccba61c8128e1c4751cea0ee87f7f50b | Rust | kooparse/fuel | /fuel_types/src/rotation.rs | UTF-8 | 499 | 3.515625 | 4 | [
"MIT"
] | permissive | use na::Vector3;
#[derive(Default, Debug, Clone)]
pub struct Rotation {
x: f32,
y: f32,
z: f32,
}
impl Rotation {
pub fn new() -> Self {
Default::default()
}
pub fn new_with_default(x: f32, y: f32, z: f32) -> Self {
Rotation { x, y, z }
}
pub fn get(&self) -> Vector3<... | true |
4ba96ff5454331bc0776c56e470f084a2ba88d23 | Rust | cideM/teems-rust | /src/apps/xterm.rs | UTF-8 | 4,025 | 2.859375 | 3 | [] | no_license | use crate::Theme;
use failure::Error;
use regex::Regex;
pub fn convert_colors(theme: &Theme, app_config: &str) -> Result<String, Error> {
let mut results: Vec<String> = vec![];
let re_line_with_color = Regex::new(
r"(?xi)
^XTerm\*
(?P<color_name>color\d+
|foreground
... | true |
13c56fcedd81ed0429dfea136b8a83e4bbf417fb | Rust | PatrickNorton/rust-runtime | /src/var_impls.rs | UTF-8 | 7,073 | 2.875 | 3 | [] | no_license | use crate::function::Function;
use crate::int_var::IntVar;
use crate::lang_union::LangUnion;
use crate::looping;
use crate::method::Method;
use crate::rational_var::RationalVar;
use crate::std_type::Type;
use crate::std_variable::StdVariable;
use crate::string_var::StringVar;
use crate::tuple::LangTuple;
use crate::var... | true |
734803aeaac8b76d52fa16d2c3a940fe885ea5d5 | Rust | gengjiawen/leetcode | /Array/_1160_find_words_that_can_be_formed_by_characters.rs | UTF-8 | 1,913 | 3.828125 | 4 | [] | no_license | // https://leetcode.com/problems/find-words-that-can-be-formed-by-characters
//
// You are given an array of strings `words` and a string `chars`.
//
// A string is **good** if it can be formed by characters from chars (each character can only be used once).
//
// Return _the sum of lengths of all good strings in words... | true |
00c6374f50a29c1bb2a66aeb51e96ad79d65291c | Rust | livexia/algorithm | /blind_75_leetcode/src/solution/s0347_top_k_frequent_elements.rs | UTF-8 | 898 | 3.453125 | 3 | [] | no_license | #![allow(dead_code)]
pub struct Solution {}
use std::collections::{BinaryHeap, HashMap};
impl Solution {
pub fn top_k_frequent(nums: Vec<i32>, k: i32) -> Vec<i32> {
let mut map = HashMap::new();
for num in nums {
*map.entry(num).or_insert(0) += 1
}
let mut heap = Binary... | true |
08a5d17b7283f4a57503945864e02f3224beb894 | Rust | catplayer233/rust-train | /smart-pointer-train/src/main.rs | UTF-8 | 3,599 | 3.203125 | 3 | [] | no_license | use std::mem::drop;
use std::rc::Rc;
use box_explorer::new_box;
use rc_explorer::RCList;
use crate::box_explorer::List::{Cons, Nil};
use crate::deref_drop_explorer::{CustomSmartPointer, hello, MyBox};
mod box_explorer;
mod deref_drop_explorer;
mod rc_explorer;
mod reference_cycle_explorer;
mod weak_reference_explore... | true |
66b4b52013446650439fb65e0d0d7528642a14da | Rust | tchamelot/drosix | /drone/src/flight_controller.rs | UTF-8 | 5,538 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::controller::{Controller, Pid};
use crate::messages::{Answer, Command};
use crate::sensor::Sensors;
use mio::unix::SourceFd;
use mio::{Events, Interest, Poll, Token};
// use std::sync::mpsc::Receiver;
use tokio::sync::mpsc::{Receiver, Sender};
use anyhow::{Context, Result};
use std::time::{Duration, Insta... | true |
e0ed03558773389e010d29e4c3a8e25a0d9025db | Rust | NyxCode/word-cloud-generator | /generator/src/spiral.rs | UTF-8 | 393 | 3.21875 | 3 | [] | no_license | use rusttype::{Point, point};
pub struct Spiral {
pub step: f32,
pub index: f32,
}
impl Spiral {
pub fn new(step: f32) -> Self {
Spiral { step, index: 0.0 }
}
pub fn next_point(&mut self) -> Point<i32> {
let x = self.index;
self.index += self.step;
p... | true |
2122c09df47a261a0d81f3922fc6dae51fd27bbf | Rust | devcooch/aoc-2018 | /src/bin/d12v1.rs | UTF-8 | 1,366 | 3 | 3 | [
"Unlicense"
] | permissive | use std::collections::HashMap;
use std::str;
fn main() {
let data = include_str!("day12.txt");
let mut lines = data.lines();
let mut state: Vec<u8> = lines.next().unwrap().trim().as_bytes().to_vec();
let zero_pos = state.iter().position(|&x| x == b'#' || x == b'.').unwrap();
state = state
.... | true |
09312d62928993ab95f93213d63c969f50cf0d7a | Rust | Tristan971/advent-of-code-2020 | /src/bin/day11/main.rs | UTF-8 | 5,262 | 2.96875 | 3 | [] | no_license | use advent_of_code_2020::common::inputs;
struct Direction {
dx: i32,
dy: i32,
}
const TL: Direction = Direction { dx: -1, dy: -1 };
const TC: Direction = Direction { dx: 0, dy: -1 };
const TR: Direction = Direction { dx: 1, dy: -1 };
const L: Direction = Direction { dx: -1, dy: 0 };
const R: Direction = Direc... | true |
432cbeb31dd2a34e3767f8cac0dd201021f15417 | Rust | DRL9/the_rust_programming_language | /add/add-one/src/lib.rs | UTF-8 | 299 | 3.140625 | 3 | [
"MIT"
] | permissive | use rand::prelude::*;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(add_one(1), 2);
}
}
pub fn add_one(a: i32) -> i32 {
a + 1
}
pub fn add_rand(a: i32) -> i32 {
let mut rng = rand::thread_rng();
let y: i32 = rng.gen();
a + y
}
| true |
85886b95b2127b87b4efcc819c9ed90135fb332f | Rust | hatoo/competitive-rust-snippets | /src/interval_heap.rs | UTF-8 | 10,846 | 3.28125 | 3 | [
"MIT"
] | permissive | use cargo_snippet::snippet;
/// IntervalHeap
#[snippet("IntervalHeap")]
#[derive(Clone, Debug)]
struct IntervalHeap<T: Ord + Eq> {
data: Vec<T>,
}
#[snippet("IntervalHeap")]
impl<T: Ord + Eq> IntervalHeap<T> {
#[allow(dead_code)]
fn new() -> IntervalHeap<T> {
IntervalHeap { data: Vec::new() }
... | true |
1c5642af351003094f471438b5fedbdd66716cd8 | Rust | BluSyn/hview | /frontend/src/components/page.rs | UTF-8 | 11,668 | 2.75 | 3 | [] | no_license | use serde::Deserialize;
use yew::format::{Json, Nothing};
use yew::prelude::*;
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::services::ConsoleService;
use yew::Properties;
use super::entry::{Entry, EntryProps};
use super::modal::{is_media, MediaType, Modal, ModalProps};
use crate::{A... | true |
e203bfcf980ef705424b826b82321c1c467f679f | Rust | satanja/Beserker-Bot | /src/main.rs | UTF-8 | 21,694 | 3.03125 | 3 | [] | no_license | mod api;
mod bout;
mod response;
use bout::Bout;
use response::{Response, ResponseType};
use std::env;
use std::{collections::HashMap, usize};
use serenity::{
async_trait,
http::Http,
model::{channel::Message, gateway::Ready},
prelude::*,
utils::Colour,
};
use serenity::client::{Client, Context, ... | true |
dea0f9e95fed76abc7202a83f96bfee01ce67d47 | Rust | 742362144/AutoLoc | /runtime/src/cycles.rs | UTF-8 | 3,751 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | /* Copyright (c) 2018 University of Utah
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DIS... | true |
134858da9867a1abb326c3a79dd95b0c946cb834 | Rust | phil-opp/RustOS-fork | /src/thread/scheduler.rs | UTF-8 | 2,918 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // TODO(ryan): it really looks like bulk of libgreen could be used here where pthread <-> core
use core::prelude::*;
//use std::one::{ONCE_INIT, Once};
use core::cell::UnsafeCell;
use core::mem::transmute;
use alloc::boxed::Box;
use collections::RingBuf;
use collections::dlist::DList;
use thread::context::Context;... | true |
dc7e88935e2d10b39728c4857d0d13b1dab12209 | Rust | algesten/ureq | /examples/mbedtls/src/mbedtls_connector.rs | UTF-8 | 3,858 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // This requires mbedtls crate 0.11.0 or newer due to
// new Context<T> parameter
use std::fmt;
use std::io;
use ureq::{Error, ReadWrite, TlsConnector};
use std::net::TcpStream;
use std::sync::{Arc, Mutex};
use mbedtls::rng::CtrDrbg;
use mbedtls::ssl::config::{Endpoint, Preset, Transport};
use mbedtls::ssl::{Config, ... | true |
cbc5eb6d00ea682a1defeab168c35a96b2800c48 | Rust | Azure/azure-sdk-for-rust | /services/mgmt/alertsmanagement/src/package_preview_2023_04/models.rs | UTF-8 | 12,460 | 2.515625 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | #![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::de::{value, Deserializer, IntoDeserializer};
use serde::{Deserialize, Serialize, Serializer};
use std::str::FromStr;
#[doc = "A pointer to an Azure Action Group."]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ActionGroup {
... | true |
8e0c12c8bca9b20235269b8b7117efeb915462fe | Rust | TrevorJTClarke/lighthouse | /beacon_node/eth2-libp2p/src/rpc/methods.rs | UTF-8 | 7,324 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | //!Available RPC methods types and ids.
use ssz::{impl_decode_via_from, impl_encode_via_from};
use ssz_derive::{Decode, Encode};
use types::{BeaconBlockBody, Epoch, EthSpec, Hash256, Slot};
/* Request/Response data structures for RPC methods */
/* Requests */
pub type RequestId = usize;
/// The HELLO request/respo... | true |
da0ea0b60443b352144e336b4ff3251b385f9055 | Rust | gahag/slizzy | /src/modules/slider/tui/renderer.rs | UTF-8 | 3,382 | 2.78125 | 3 | [] | permissive | use std::borrow::Cow;
use tui::{
buffer::Buffer,
layout::{Rect, Corner},
style::{Color, Style},
widgets::{Block, Borders, Text, List, Widget},
};
use crate::util::bytes;
use super::{ItemStatus, Status, Filter};
pub struct Renderer<'a>(pub &'a super::Widget);
impl<'a> Renderer<'a> {
fn render_title(&self) -> ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.