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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
894ee1f2e51ffd43db1b1085549bd05313e3e3d7 | Rust | Lycowolf/streaming_deckbuilder | /src/game_objects.rs | UTF-8 | 8,453 | 2.59375 | 3 | [] | no_license | extern crate quicksilver;
extern crate json;
use rand::thread_rng;
use rand::seq::SliceRandom;
use quicksilver::prelude::*;
use std::collections::VecDeque;
use std::collections::HashMap;
use serde_derive::*;
use itertools::Itertools;
use itertools::izip;
use std::iter;
use std::fmt;
use crate::game_logic::BoardState;
... | true |
21703a0364912ec111a1e1fd8c4f0d3b500c7db6 | Rust | gkorland/wickdb | /src/util/status.rs | UTF-8 | 4,250 | 2.59375 | 3 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | // Copyright 2019 Fullstop000 <fullstop1005@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 required by appli... | true |
2610f7ebe85f739cf51fe730349d3a0c498f1b7b | Rust | pes-magic/procon | /AtCoder/ABC311/src/bin/b.rs | UTF-8 | 383 | 2.84375 | 3 | [] | no_license | use proconio::input;
use proconio::marker::Chars;
fn main() {
input! {
n:usize, d:usize,
s: [Chars;n]
}
let mut res = 0;
let mut cur = 0;
for i in 0..d {
if (0..n).into_iter().all(|j| s[j][i] == 'o') {
cur = cur + 1;
} else {
cur = 0;
... | true |
a5108b2400091b0dcf16983e06ea79c90f54a6ff | Rust | hpatjens/iwgui | /examples/main.rs | UTF-8 | 3,828 | 2.671875 | 3 | [
"MIT"
] | permissive | use iwgui::*;
use log::LevelFilter;
use simple_logger::SimpleLogger;
use std::{thread, time::Duration};
struct Duck {
name: String,
in_the_water: bool,
}
struct PaperPlane {
paper_size: usize,
name: String,
}
struct Model {
ducks_at_the_pont: Vec<Duck>,
paper_planes: Vec<PaperPlane>,
}
impl... | true |
274902895960240cb26b8f01101dc365f4539533 | Rust | sogapalag/contest | /atcoder/pakencamp-2020-day1/j.rs | UTF-8 | 666 | 2.90625 | 3 | [] | no_license | #[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
fn solve() {
let out = std::io::stdout();
let mut out = BufWriter::new(out.lock());
macro_rules! puts {
($($format:tt)*) => (let _ = write!(out,$($format)*););
}
for ... | true |
f9fbf2fb00160e20821defd30204c6e036c22005 | Rust | seanwallawalla-forks/nushell | /crates/nu-command/src/commands/dataframe/to_df.rs | UTF-8 | 968 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::{dataframe::NuDataFrame, Signature};
pub struct DataFrame;
impl WholeStreamCommand for DataFrame {
fn name(&self) -> &str {
"dataframe to-df"
}
fn usage(&self) -> &str {
"Converts a pipel... | true |
8e0fdc347b86af7a05a5672b7e51a16aa515e185 | Rust | MurphyKyle/apex_dma_kvm_pub | /apex_dma/memflow_lib/memflow-ffi/src/mem/virt_mem.rs | UTF-8 | 3,567 | 2.921875 | 3 | [
"MIT"
] | permissive | use memflow::error::PartialResultExt;
use memflow::mem::virt_mem::*;
use memflow::types::Address;
use crate::util::*;
use std::slice::{from_raw_parts, from_raw_parts_mut};
pub type VirtualMemoryObj = &'static mut dyn VirtualMemory;
/// Free a virtual memory object reference
///
/// This function frees the reference... | true |
088e106324526675228e9862d2961145f0631b55 | Rust | Ophirr33/rgo | /src/lexer/mod.rs | UTF-8 | 18,901 | 3.703125 | 4 | [] | no_license | //! # Lexer
//!
//! A `Lexer` parses a source string into a list of tokens, which may later be used to construct an
//! Abstract Syntax Tree.
//!
//! ## Notes
//!
//! - We want meaningful errors from the start. That means printing the line and column number on
//! error, returning `Result`s instead of panicking (later ... | true |
486bc457fe36427b5079cff1d574c6bd580ec821 | Rust | oliver-giersch/hazptr | /examples/treiber/main.rs | UTF-8 | 1,879 | 2.984375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::mem;
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
};
use std::thread;
mod stack;
use crate::stack::Stack;
#[repr(align(64))]
struct ThreadCount(AtomicUsize);
struct DropCount<'a>(&'a AtomicUsize);
impl Drop for DropCount<'_> {
fn drop(&mut self) {
self.0.fetch_add(1, Ordering:... | true |
1eba3ec989cb4556318621d10018d04143b9b40d | Rust | wang-q/intspan | /src/cmd_ovlpr/restrict.rs | UTF-8 | 2,144 | 2.78125 | 3 | [
"MIT"
] | permissive | use clap::*;
use intspan::*;
use std::collections::HashSet;
use std::io::BufRead;
// Create clap subcommand arguments
pub fn make_subcommand() -> Command {
Command::new("restrict")
.about("Restrict overlaps to known pairs")
.arg(
Arg::new("infile")
.required(true)
... | true |
b9261907a916fe03436952af724a1b8c007432ba | Rust | iliekturtles/uom | /src/si/areal_mass_density.rs | UTF-8 | 2,244 | 3.203125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Areal mass density (base unit kilogram per square meter, m⁻² · kg).
quantity! {
/// Areal mass density (base unit kilogram per square meter, m⁻² · kg).
quantity: ArealMassDensity; "areal mass density";
/// Dimension of areal mass density, L⁻²M (base unit kilogram per square meter, m⁻² · kg).
dimens... | true |
03286525abf357a74d5fca49ea7c0732dd44dcbc | Rust | SteelPh0enix/gbyteint | /src/interpreter.rs | UTF-8 | 3,376 | 3.765625 | 4 | [
"MIT"
] | permissive | use command::Command;
use processor::Processor;
use std::collections::BTreeMap;
#[derive(Debug)]
pub struct Interpreter<T> {
processor: Processor<T>,
commands: BTreeMap<String, Command<T>>,
}
#[derive(Debug)]
pub enum InterpreterError {
CommandNotFound,
}
impl<T> Interpreter<T>
where
T: Default,
{
... | true |
ef2f2d88eb8aba49d8920497a2209d62cc90b553 | Rust | sts10/advent-of-code-2020-rust | /src/bin/day08-part2.rs | UTF-8 | 4,140 | 3.328125 | 3 | [
"BlueOak-1.0.0"
] | permissive | use advent_of_code_2020::{read_by_line, split_and_vectorize};
#[derive(Debug, Clone)]
struct Head {
accumulator: isize,
current_position: usize,
trail_of_positions: Vec<usize>,
}
fn main() {
let file_name = "inputs/day08.txt";
let instructions: Vec<String> = read_by_line(file_name).unwrap();
l... | true |
963baf9248ec066f604b2dd66b1d278edc3de227 | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/png-0.14.0/src/encoder.rs | UTF-8 | 7,881 | 2.671875 | 3 | [
"BSD-2-Clause",
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate deflate;
use std::borrow::Cow;
use std::error;
use std::fmt;
use std::io::{self, Write};
use std::mem;
use std::result;
use chunk;
use crc::Crc32;
use common::{Info, ColorType, BitDepth, Compression};
use filter::{FilterType, filter};
use traits::{WriteBytesExt, HasParameters, Parameter};
pub type Resul... | true |
17e3ca53c9aa0dc7cab96c16203b8bda02605209 | Rust | erikjara/rut-lib | /examples/format.rs | UTF-8 | 278 | 2.828125 | 3 | [
"MIT"
] | permissive | use rut_lib::{Format, Rut};
fn main() {
let input = "179515857";
let rut = Rut::from(input).unwrap();
println!("Dots: {}", rut.to_format(Format::DOTS));
println!("Dash: {}", rut.to_format(Format::DASH));
println!("None: {}", rut.to_format(Format::NONE))
}
| true |
7262f719b03e175faed6539b5f24b5510147bdad | Rust | chin0/everydayalgo | /baekjoon/string/prob1157/src/main.rs | UTF-8 | 612 | 2.96875 | 3 | [] | no_license | use std::io::stdin;
fn main() {
let mut s = String::new();
stdin().read_line(&mut s).expect("failed to read.");
let s = s.trim().to_ascii_uppercase();
let mut cntlist = [0; 26];
s.bytes().for_each(|x| cntlist[(x - b'A') as usize] += 1);
let mut max = s.as_bytes()[0];
for c in s.bytes().ski... | true |
1275a0b7558bb9af3fa8bb520d47b2238494e216 | Rust | mciantyre/python-config-rs | /src/lib.rs | UTF-8 | 16,515 | 3.296875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! # python-config-rs
//!
//! Just like the `python3-config` script that's installed
//! with your Python distribution, `python-config-rs` helps you
//! find information about your Python distribution.
//!
//! ```no_run
//! use python_config::PythonConfig;
//!
//! let cfg = PythonConfig::new(); // Python 3
//!
//! // ... | true |
b9d73c307d195546d43a44e03ce912b0c7377a07 | Rust | boa-dev/boa | /boa_engine/src/vm/completion_record.rs | UTF-8 | 1,660 | 3.125 | 3 | [
"MIT",
"Unlicense"
] | permissive | //! An implementation of a `CompletionRecord` for Boa's VM.
use boa_gc::{custom_trace, Finalize, Trace};
use crate::{JsError, JsResult, JsValue};
/// An implementation of the ECMAScript's `CompletionRecord` [specification] for
/// Boa's VM output Completion and Result.
///
/// [specification]: https://tc39.es/ecma26... | true |
5fbbaedd54816dbf1d1679a062cfd53a84c40510 | Rust | LawnGnome/waybar-custom-modules | /mem/src/main.rs | UTF-8 | 1,985 | 2.734375 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use humantime::Duration;
use std::{fs, str};
use structopt::StructOpt;
use waybar::{History, Loop, Output, Percentage};
#[derive(Debug, StructOpt)]
struct Opt {
#[structopt(short, long, default_value = "mem", help = "CSS class")]
class: String,
#[structopt(short, long, default_value = ... | true |
a88638ad3523d61860fd342e28cabbf70d7e1845 | Rust | Boscop/web-view | /webview-examples/examples/color_change.rs | UTF-8 | 858 | 2.828125 | 3 | [
"MIT"
] | permissive | extern crate web_view;
use web_view::*;
fn main() {
web_view::builder()
.title("Change background color")
.content(Content::Html(HTML))
.size(200, 100)
.resizable(true)
.debug(true)
.user_data("")
.invoke_handler(|webview, arg| {
match arg {
... | true |
54ace617a66b0ac8edce0d112e6881daaa6133ff | Rust | museun/usml | /src/stack.rs | UTF-8 | 1,991 | 3.734375 | 4 | [] | no_license | #[derive(Clone, Default)]
pub struct Stack<T> {
inner: Vec<T>,
}
impl<T> Stack<T> {
pub const fn new() -> Self {
Self { inner: Vec::new() }
}
pub fn with_capacity(size: usize) -> Self {
Self {
inner: Vec::with_capacity(size),
}
}
pub fn len(&self) -> usize ... | true |
b1d8e6be461cd1ae35c7280fd4566dd0725ba79f | Rust | farallons/sea-lion | /prime/src/main.rs | UTF-8 | 813 | 2.859375 | 3 | [
"MIT"
] | permissive | use prime::Generator;
use prime;
use std::env;
#[allow(unused_variables)]
fn main() {
let args: Vec<String> = env::args().collect();
let args_count = args.len();
let mut generator = match args.len() {
1 => Generator::new(),
2 => {
let n = match u32::from_str_radix(&args[1], 10) ... | true |
d9d6ff7251f32fb3b2ccb81d8849fc4698f5af7a | Rust | atoav/bender-bouncer | /src/bin/bender-bouncer-cli.rs | UTF-8 | 3,378 | 3.109375 | 3 | [
"MIT"
] | permissive | #[macro_use] extern crate serde_derive;
extern crate docopt;
extern crate colored;
extern crate bender_bouncer;
use docopt::Docopt;
use colored::*;
use bender_bouncer::{check_blend};
const USAGE: &str = "
bender_bouncer
The bouncer verifies wether one or more files are valid blend files. If so, bouncer
returns the ... | true |
75bc0e52fcc20c5569c22d43567aaf22fd3972ff | Rust | ClementTsang/bottom | /src/canvas/widgets/process_table.rs | UTF-8 | 12,876 | 2.515625 | 3 | [
"MIT"
] | permissive | use tui::{
backend::Backend,
layout::{Alignment, Constraint, Direction, Layout, Rect},
style::Style,
terminal::Frame,
text::{Line, Span},
widgets::{Block, Borders, Paragraph},
};
use unicode_segmentation::UnicodeSegmentation;
use crate::{
app::{App, AppSearchState},
canvas::Painter,
... | true |
b92d1911ad5fe73a9263c8cc1d45dcd176d0cd41 | Rust | adriensamson/aoc2018 | /src/day10/mod.rs | UTF-8 | 2,734 | 3.34375 | 3 | [] | no_license | use regex::Regex;
use std::str::FromStr;
pub fn step1(input : String) {
let points = parse_points(&input);
let mut t = 0;
let mut coords = get_points_at(&points, 0);
let mut area = get_area(&coords);
loop {
t += 1;
let new_coords = get_points_at(&points, t);
let new_area = g... | true |
0baf36e264e778b45a59bb7c111cbc4b135e8954 | Rust | rustwasm/wasm-bindgen | /crates/backend/src/encode.rs | UTF-8 | 16,555 | 2.84375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::util::ShortHash;
use proc_macro2::{Ident, Span};
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::env;
use std::fs;
use std::path::PathBuf;
use crate::ast;
use crate::Diagnostic;
pub struct EncodeResult {
pub custom_section: Vec<u8>,
pub included_files: Vec<PathBuf>,
}
pub f... | true |
88dd7d4604eec318e54fee7b189ce7836da6a321 | Rust | baajarmeh/serlo.org-database-layer | /src/datetime.rs | UTF-8 | 2,998 | 3.34375 | 3 | [
"Apache-2.0"
] | permissive | //! Provides a custom DateTime `newtype` that deals with timestamp inconsistencies in our database.
//!
//! The timestamps in our database are persisted as UTC but are actually Europe/Berlin. So we need
//! to manipulate the timestamps accordingly. See [`DateTime`].
use std::fmt;
use chrono::{Duration, TimeZone, Utc};... | true |
184a67ec369a270c27c0ffc73ba471a0af186aaa | Rust | 0xjac/nym-mixnode | /src/mix_peer.rs | UTF-8 | 961 | 2.875 | 3 | [] | no_license | use std::error::Error;
use std::net::{Ipv4Addr, SocketAddrV4};
use tokio::prelude::*;
#[derive(Debug)]
pub struct MixPeer {
connection: SocketAddrV4,
}
impl MixPeer {
// note that very soon `next_hop_address` will be changed to `next_hop_metadata`
pub fn new(next_hop_address: [u8; 32]) -> MixPeer {
... | true |
4349a230eb92dccb967240611f51e9380c82953b | Rust | Anphamthanh/brain-games-rust | /src/play.rs | UTF-8 | 1,735 | 3.15625 | 3 | [] | no_license | use crate::board::{Board, BoardSpaceState, GameResult, Player};
use crate::bot::Bot;
pub fn play(board: &mut Board, player_x: &mut Bot, player_o: &mut Bot) -> Option<GameResult> {
let mut current_player: Player = Player::X;
let mut winner: Option<GameResult> = None;
let mut moves_available = true;
whi... | true |
a5ef6bdeea9270d1ec1cca6f4f8dd35e304d0f1a | Rust | spielrs/yew_vnode_struct | /src/lib.rs | UTF-8 | 2,516 | 3.15625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! This module contains the implementation to get all the VNode structure.
//! it is useful for testing and debuging. For example to know what contain this VNode
//! we use VNodeStruct to get the complete Vnode button and log the result:
//!
//! #Example
//!
//! ```
//! extern crate yew;
//! extern crate yew_vnode_str... | true |
2c95f941af26d5c7b6fef55f533bf06463abc358 | Rust | stormpat/Problems | /euler/rust/4.rs | UTF-8 | 449 | 3.171875 | 3 | [] | no_license |
//return max(a * b for a in range(1,1000) for b in range(a,1000) if str(a * b) == str(a * b)[::-1])
fn main() {
let problem = 4i;
println!("Euler problem {} \n", problem);
// Begin problem
}
fn palindrome() -> int {
for n in range(100,1000) {
for nx in range(100,1000) {
let mut sum = n * nx;
... | true |
d00337af687fd8e6904432f57353facd9152dde0 | Rust | horou-dsk/rust-snake | /desktop/src/render_text.rs | UTF-8 | 2,024 | 3.0625 | 3 | [] | no_license | use sdl2::pixels::Color;
use sdl2::ttf::{FontStyle, Sdl2TtfContext};
use std::env;
use std::path::Path;
use sdl2::render::{WindowCanvas, TextureQuery};
use sdl2::rect::Rect;
pub fn draw_text(text: &mut Text, ttf_context: &Sdl2TtfContext, canvas: &mut WindowCanvas) {
let windir = env::var("windir").unwrap();
le... | true |
96a6283af809131b8684b215c81327ca00238d62 | Rust | kenchan/competitive_programming | /atcoder/abc282/src/bin/b.rs | UTF-8 | 482 | 2.96875 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
n: usize,
_m: usize,
s: [String; n],
}
let mut ans = 0;
for i in 0..n {
for j in (i + 1)..n {
let str1 = &s[i];
let str2 = &s[j];
if str1
.chars()
.zip(str2.c... | true |
4b34b3661995490331156cf2286b425cc138997a | Rust | biaoma-ty/arrow-datafusion | /datafusion/expr/src/tree_node/plan.rs | UTF-8 | 4,759 | 2.515625 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
9fc1fd6652f76f44fe6f63e4e7596942a2b45119 | Rust | expenses/line_drawing | /src/bresenham_circle.rs | UTF-8 | 2,307 | 3.75 | 4 | [
"MIT"
] | permissive | use {Point, SignedNum};
/// An implementation of [Bresenham's circle algorithm].
///
/// This uses four quadrants, so calling `next()` will return a point for the first quadrant,
/// then the second, third, fourth and then back to first.
///
/// Example:
///
/// ```
/// extern crate line_drawing;
/// use line_drawing:... | true |
2797cb0ca61e588044b6a4e9c6543781c51016f9 | Rust | Orca-bit/DataStructureAndAlgorithm | /src/string_problem/_3_length_of_longest_substring.rs | UTF-8 | 1,021 | 3.515625 | 4 | [] | no_license | struct Solution;
impl Solution {
pub fn length_of_longest_substring(s: String) -> i32 {
if s.is_empty() {
return 0;
}
let s = s.bytes().collect::<Vec<_>>();
let mut map = vec![-1; 256];
let mut res = 0;
let mut pre = -1;
for (index, &ch) in s.iter... | true |
2839646c7ad81de67fec6d08cfeb48f4d36e7dbf | Rust | svartalf/tokio-memcache | /src/protocol/extras.rs | UTF-8 | 1,462 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #![allow(dead_code)]
use std::io;
use byteorder::{NetworkEndian, WriteBytesExt};
use super::{Extras, IntoValue};
/// Extras for `get`/`getq`/`getk`/`getkq` commands.
#[derive(Default)]
pub struct GetExtras {
pub flags: u32,
}
impl IntoValue for GetExtras {
fn write<T: io::Write>(&self, buf: &mut T) -> io::... | true |
1fd3dca8c1dc7f1d9b1ca35e106f7ea78c3df9b4 | Rust | shaunbennett/lucis | /src/scene/light.rs | UTF-8 | 3,201 | 3.265625 | 3 | [
"MIT"
] | permissive | use crate::scene::Color;
use nalgebra::Point3;
use rand::{thread_rng, Rng};
use std::default::Default;
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct Light {
// The color of the light
pub color: Color,
// Position of the light in 3d space
pub position: Point3<f32>,
pub falloff: [f32; 3],... | true |
fecb76d9f35958cbd4c6ed7f8b40583cdf37d679 | Rust | 2d-rpg/card-playroom-server | /src/index.rs | UTF-8 | 604 | 2.59375 | 3 | [] | no_license | /**
* 管理画面のトップページ
* http://localhost:8080
*/
use actix_web::{error, web, Error, HttpResponse};
use tera::Tera;
async fn index(tmpl: web::Data<tera::Tera>) -> Result<HttpResponse, Error> {
let ctx = tera::Context::new();
let view = tmpl
.render("index.html", &ctx)
.map_err(|e| error::ErrorInt... | true |
3569aa04951d49bdec0bede7239b2cf658894bcf | Rust | provable-things/ptokens-core | /src/metadata/metadata_protocol_id.rs | UTF-8 | 1,900 | 3.1875 | 3 | [] | no_license | use std::fmt;
#[cfg(test)]
use strum::IntoEnumIterator;
use strum_macros::EnumIter;
use crate::types::Byte;
#[cfg(test)]
use crate::types::Result;
#[derive(Clone, Debug, PartialEq, Eq, EnumIter)]
pub enum MetadataProtocolId {
Bitcoin,
Ethereum,
Eos,
}
impl MetadataProtocolId {
pub fn to_byte(&self) ... | true |
a5b28c1dc1fd1c7f1256e51c9526a048c7d4fc9c | Rust | singpolyma/rustache | /src/build.rs | UTF-8 | 13,482 | 3.59375 | 4 | [
"MIT"
] | permissive | use std::cell::RefCell;
use std::collections::HashMap;
use Data;
use Data::{Strng, Bool, Integer, Float, Vector, Hash, Lambda};
/// `HashBuilder` is a helper type that constructs `Data` types in a HashMap
#[derive(Debug)]
pub struct HashBuilder<'a> {
#[doc(hidden)]
pub data: HashMap<String, Data<'a>>,
#[d... | true |
99a17226510903a8efe3729c3c0edace149e9b4d | Rust | nisarhassan12/materialize | /src/storage-client/src/ssh_tunnels.rs | UTF-8 | 9,546 | 2.578125 | 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.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by ... | true |
f9d63d1a5859fda1e8695237697b6dcbce68a0d4 | Rust | cezarmathe/gossip-bot | /src/storage/mod.rs | UTF-8 | 2,644 | 2.84375 | 3 | [
"MIT"
] | permissive | //! Storage-related module
mod model;
pub mod prelude {
pub use super::DatabaseWrapper;
pub use super::model::*;
pub use super::repository::*;
}
mod repository;
mod schema;
use std::mem::MaybeUninit;
use std::sync::Once;
use diesel::r2d2::ConnectionManager;
use diesel::r2d2::Pool;
use diesel::SqliteConn... | true |
e807b8137ee13095d27b79d66d2b42add36459cf | Rust | LeeMartin77/orbital_bevy | /src/systems/setup.rs | UTF-8 | 3,120 | 2.671875 | 3 | [] | no_license | use bevy::prelude::*;
use bevy_prototype_lyon::prelude::*;
use crate::components::*;
use crate::systems::ui::UiExtensions;
pub fn setup(
mut commands: Commands,
asset_server: Res<AssetServer>
) {
commands.add_player();
let planet_radius = 10.0;
let planet_density = 12000000000.0;
commands.ad... | true |
c1be602d8da75c92df560246de725779f327aa05 | Rust | libdist-rs/libchatter-rs | /consensus/artemis/src/node/context.rs | UTF-8 | 9,173 | 2.53125 | 3 | [] | no_license | use std::{collections::VecDeque, convert::TryInto};
use crypto::hash::Hash;
use crypto::{Keypair, PublicKey, ed25519, secp256k1};
use futures::channel::mpsc::UnboundedSender;
use types::artemis::{Block, ClientMsg, GENESIS_BLOCK, ProtocolMsg, Replica, Round, Storage, UCRVote, View};
use config::Node;
use std::sync::Arc;... | true |
09bb24ae187faa0aab1c463dc77e29f8b7d8c621 | Rust | PurpleMyst/aoc-2019 | /day10/src/main.rs | UTF-8 | 2,462 | 3.296875 | 3 | [] | no_license | use std::{
collections::{BinaryHeap, HashMap},
f64::consts::{FRAC_PI_2, PI},
hash::{Hash, Hasher},
hint::unreachable_unchecked,
iter::FromIterator,
};
#[derive(Clone, Copy, Debug, PartialEq)]
struct OrderedFloat(f64);
impl Eq for OrderedFloat {}
impl PartialOrd for OrderedFloat {
fn partial_c... | true |
2cca1b41c4e8c0abd1e7d1b99c09061d1777bab7 | Rust | darshanparajuli/AdventOfCode2019 | /src/bin/day2.rs | UTF-8 | 1,704 | 3.078125 | 3 | [] | no_license | use aoc_2019::read_input;
fn main() {
let input = read_input()
.iter()
.flat_map(|line| {
line.split(",")
.map(|a| a.parse::<i32>())
.collect::<Result<Vec<_>, _>>()
})
.flatten()
.collect::<Vec<_>>();
part1(input.clone());
... | true |
cd3795b99f2b57adc090b2812adf9abe09782151 | Rust | rcore-os-infohub/ossoc2020-Wintersweet0-daily | /learn c the hard way/ex2/ex2.rs | UTF-8 | 89 | 2.984375 | 3 | [] | no_license | fn main() {
let distance = 100;
println!("You are {} miles away.\n", distance);
} | true |
a18edad67a38d92b2a49853aa86cd243579a3c20 | Rust | ticklepoke/parser-combinator | /src/core/parser_state.rs | UTF-8 | 428 | 3.140625 | 3 | [] | no_license | #[derive(Debug, Clone, PartialEq)]
pub struct ParserState {
pub target: String,
pub index: usize,
pub result: Option<String>,
}
impl ParserState {
pub fn new(target: String, index: usize) -> Self {
ParserState {
target,
index,
result: Some("".to_owned()),
... | true |
a4b2e10edbde2f9dfc272dd9e55ebe8e2206bfa5 | Rust | daisuzz/toy-rdbms | /src/table.rs | UTF-8 | 1,998 | 2.890625 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use crate::btree::BTree;
use crate::buffer_pool_manager::BufferPoolManager;
use crate::disk_manager::PageId;
use crate::query::UniqueIndex;
use crate::tuple;
pub struct SimpleTable {
pub meta_page_id: PageId,
pub num_key_elements: usize, //左からいくつの列がprimary keyかを表す
}
impl SimpleTable {
... | true |
65a17aa8bf78c9f8c01f2eb74bee23c904469f75 | Rust | workanator/shapir | /src/api/shares/share.rs | UTF-8 | 10,420 | 2.96875 | 3 | [
"MIT"
] | permissive | use chrono::prelude::*;
use serde_json::Value;
use ::error::{Result, Error, IoError, IoErrorKind};
use super::{Kind, AccessRight};
/// Share Details
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Share {
/// Share type: Send or Request.
pub kind: Kind,
/// Access rights for the share.
... | true |
5d8d777e0a08480a5ee51002738cce7cb99cfb86 | Rust | wezm/cc2650 | /src/trng/cfg0.rs | UTF-8 | 9,055 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | 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::CFG0 {
#[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 |
771064eeca9d5f7a71acc1457a5983df61fced53 | Rust | niuyuling/denyhosts | /clamav/libclamav_rust/src/logging.rs | UTF-8 | 2,766 | 2.703125 | 3 | [] | no_license | /*
* Rust logging module
*
* Copyright (C) 2021-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
*
* Authors: Mickey Sola
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Fre... | true |
40e0c8bffa25edf1daefaa00d9370492dfdb13a1 | Rust | kattrali/webkitten | /webkitten-gtk/src/ui/window.rs | UTF-8 | 3,138 | 2.875 | 3 | [
"BSD-2-Clause"
] | permissive | use std::mem::transmute;
use std::ffi::CString;
use super::gtk_sys;
use super::gtk_sys::{GtkWindow,GtkContainer,GtkWidget};
use super::{WebView,
BoxContainer,
TextField,
FlowDirection,
GtkContainerConvertible,
GtkWidgetConvertible};
pub struct Window {
a... | true |
40cf52c058996196fdc4106cd616b6f3acba5cdf | Rust | azuline/aoc2020 | /rust/src/day21.rs | UTF-8 | 3,238 | 3.25 | 3 | [
"Apache-2.0"
] | permissive | use itertools::Itertools;
use std::collections::{HashMap, HashSet};
static INPUT: &str = include_str!("../../inputs/day21.txt");
type Ingredient = &'static str;
type Allergen = &'static str;
type Ingredients = HashSet<Ingredient>;
type Foods = HashMap<Allergen, Vec<Ingredients>>;
type Data = (Foods, Vec<Ingredients>... | true |
0ce59fe990d9c69df42f69e54786a2712098d2d6 | Rust | thunderbiscuit/bitcoin-bird-bot | /src/main.rs | UTF-8 | 1,222 | 2.890625 | 3 | [] | no_license | mod config;
mod tweet;
use egg_mode::Token;
use rand::Rng;
use egg_mode::tweet::DraftTweet;
use std::io::Read;
use std::fs::File;
use crate::config::Config;
use crate::tweet::Tweet;
#[tokio::main]
async fn main() {
// load twitter tokens from config file
let config: Config = Config::load();
// crea... | true |
c40c8ce7a8951f06ef675939ad6341f2cb37159c | Rust | sarvex/coreutils | /tests/by-util/test_yes.rs | UTF-8 | 1,956 | 2.96875 | 3 | [
"MIT",
"GPL-1.0-or-later",
"GPL-3.0-or-later"
] | permissive | use std::io::Read;
use crate::common::util::*;
/// Run `yes`, capture some of the output, close the pipe, and verify it.
fn run(args: &[&str], expected: &[u8]) {
let mut cmd = new_ucmd!();
let mut child = cmd.args(args).run_no_wait();
let mut stdout = child.stdout.take().unwrap();
let mut buf = vec![0... | true |
5d16f08f5955ce096e36f91a4d2234aa99e5674a | Rust | tocklime/aoc-rs | /aoc/src/solutions/y2016/day16.rs | UTF-8 | 1,129 | 3.1875 | 3 | [] | no_license | use aoc_harness::aoc_main;
aoc_main!(2016 day 16, part1 [p1], part2 [p2]);
fn expand(a: &mut Vec<char>) {
let len = a.len();
a.push('0');
for ix in (0..len).rev() {
a.push(match a.get(ix) {
Some('0') => '1',
_ => '0',
});
}
}
fn collapse(a: &[char]) -> Vec<char>... | true |
e5d1180e9b8e744ed2a599cc8a3c7d4d2a504a71 | Rust | katoozi/rust-practices | /collections/tuples/src/main.rs | UTF-8 | 174 | 2.890625 | 3 | [
"Unlicense"
] | permissive | fn main() {
let num_and_str: (u32, &str) = (10, "test");
println!("{:?}", num_and_str);
let (num, string) = num_and_str;
println!("{}, {}", num, string);
}
| true |
a95f318386ad65faecaf996202498d4a2e248d3d | Rust | ia7ck/competitive-programming | /AtCoder/abc303/src/bin/a/main.rs | UTF-8 | 542 | 3.03125 | 3 | [] | no_license | use proconio::{input, marker::Chars};
fn similar(x: char, y: char) -> bool {
x == y
|| (x == '1' && y == 'l')
|| (x == 'l' && y == '1')
|| (x == '0' && y == 'o')
|| (x == 'o' && y == '0')
}
fn main() {
input! {
n: usize,
s: Chars,
t: Chars,
};
l... | true |
e752af9c07be0c6afe27552e1373c3887165ba0f | Rust | kompendium-ano/factom-did-rust | /src/client/encryptor.rs | UTF-8 | 6,276 | 2.75 | 3 | [
"MIT"
] | permissive | use std::*;
use std::collections::HashMap;
use base64::{urlsafe_b64decode};
use Crypto::Cipher::{AES};
use Crypto::Hash::{SHA256, HMAC};
use Crypto::Protocol::KDF::{PBKDF2};
let all = vec!["encrypt_keys", "decrypt_keys_from_str", "decrypt_keys_from_json_str", "decrypt_keys_from_json_file"];
fn encrypt_keys<T0, T1, T2,... | true |
cf22d706aedd530c8e33729f836bbe35f203765c | Rust | happydpc/Horizon | /src/renderer/primitives/lights/pointlight.rs | UTF-8 | 1,099 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use bytemuck::*;
use specs::*;
#[derive(Component)]
#[storage(VecStorage)]
pub struct PointLight {
position: glm::Vec3,
color: wgpu::Color,
constant: f32,
linear: f32,
quadratic: f32,
}
#[repr(C)]
#[derive(Clone, Copy, Pod, Zeroable)]
pub struct PointLightRaw {
pos: [f32; 4],
color: [f32; 4]... | true |
e4f477f5cb486c9318b52edb4f54543f3445d125 | Rust | feather-rs/feather | /feather/old/server/player/src/broadcasters/block.rs | UTF-8 | 3,395 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | //! Broadcasting of block updates, i.e. when a block is changed to another.
use crate::packet_handlers::Digging;
use crate::{FinishDiggingEvent, StartDiggingEvent};
use feather_core::network::packets::{BlockBreakAnimation, BlockChange, Effect};
use feather_server_types::{BlockUpdateCause, BlockUpdateEvent, BumpVec, Ga... | true |
a67c5390c3a391061a2bd7596cab7b0466fb6697 | Rust | TonyMooori/SimpleLisp | /src/evaluater.rs | UTF-8 | 40,469 | 3.15625 | 3 | [
"MIT"
] | permissive | use interpreter::Interpreter;
use types::{MalType,BuiltInFunction};
use core::*;
use std::process::exit;
use std::collections::HashMap;
impl Interpreter{
pub fn eval(&mut self,mut ast:MalType)-> Result<MalType,String>{
let mut result : Result<MalType,String> = Ok(MalType::Nil);
let env_level = self... | true |
6dcf3b31431f20e966a0d1b69847dfb1c6dafe84 | Rust | nicholastmosher/altctrl | /src/chungo.rs | UTF-8 | 1,755 | 2.65625 | 3 | [
"MIT"
] | permissive | // Binary file using a serial communication protocol to the client
#![allow(dead_code)]
use std::io;
use std::io::{BufRead, BufReader, Write};
use std::sync::mpsc::{Receiver, Sender};
use std::thread;
mod gui;
mod i2c;
mod protocol;
mod shared;
use protocol::{IncomingMsg, OutgoingMsg};
use shared::{Event, SerialEve... | true |
d95ab06e7f45b94e5c522b6c90321039477e4eb0 | Rust | LucasForster/day-plans | /src/search.rs | UTF-8 | 8,080 | 2.546875 | 3 | [] | no_license | use super::capacities::Capacities;
use super::filters::{Filter, FilterParams, PotentialPath};
use super::graph::{Edge, Graph, Node};
use super::purposes::Purpose;
use petgraph::graph::{EdgeIndex, NodeIndex};
use rayon::prelude::*;
use std::sync::Arc;
use std::time::SystemTime;
const NUMBER_OF_CHUNKS: usize = 100;
cons... | true |
63f6e929d4357c587cc6d8bf7c0f493f29ed571e | Rust | hacmorgan/csv-plot | /src/args.rs | UTF-8 | 9,742 | 2.890625 | 3 | [] | no_license | extern crate clap;
use std::convert::TryInto;
use crate::Dataset;
pub fn initialise() -> (Vec< Dataset >, bool)
{
fn check_verbose( args : &clap::ArgMatches<'static> ) -> bool
{
if args.is_present("verbose") {
true
} else {
false
}
}
fn check_explain( ... | true |
1af2f0da0f753e3c04461cd5d3544bc8db53705d | Rust | Rustinante/analytic | /src/interval/traits.rs | UTF-8 | 967 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | use crate::set::traits::Set;
use num::Num;
/// A one-dimensional interval with a start and an end.
/// Whether or not the start and end elements are included in the interval depends
/// on the actual implementor type
pub trait Interval<T>: Set<T>
where
T: Num + Copy, {
fn from_boundaries(start: T, end_inclusiv... | true |
4fa4e0913902997820d3385b25fce4f2f16f21e7 | Rust | pgoreutn/rust-authentication-microservice | /server/src/identity/mod.rs | UTF-8 | 378 | 2.75 | 3 | [
"MIT"
] | permissive | /// Identites are methods of authenticating an account.
///
/// Identities have a many-to-one relationship with accounts, meaning that one account can be
/// identitied with multiple methods.
///
/// This allows support for third-party sign-in providers such as Google and Facebook.
///
/// Currently only password ident... | true |
08436f67aa8adf46278486ec6b1602755b09b6e2 | Rust | dpogretskiy/pcars2-power-graphs | /src/graphs/mod.rs | UTF-8 | 9,092 | 2.546875 | 3 | [
"MIT"
] | permissive | pub mod nets;
mod gears;
mod rollndiff;
pub use self::gears::*;
use self::nets::*;
pub use self::rollndiff::*;
use definitions::*;
use ggez::graphics::*;
use ggez::*;
use std::cmp::Ordering;
use std::collections::{BTreeMap, VecDeque};
use std::f32;
pub struct GraphLine {
step: i32,
draw_dot: bool,
draw_... | true |
ed5d082db195692ec458e3d6107550d8239db3fc | Rust | pearzl/leetcode_rust | /src/answer/q0106_construct_binary_tree_from_inorder_and_postorder_traversal.rs | UTF-8 | 1,659 | 3.40625 | 3 | [] | no_license | // q0106_construct_binary_tree_from_inorder_and_postorder_traversal
struct Solution;
use crate::util::TreeNode;
use std::cell::RefCell;
use std::rc::Rc;
impl Solution {
pub fn build_tree(inorder: Vec<i32>, postorder: Vec<i32>) -> Option<Rc<RefCell<TreeNode>>> {
Solution::build_tree1(&inorder, &postorder)... | true |
07249b055462babe16bdadfb5cbccf478980dde4 | Rust | iCodeIN/rust-dangerous | /src/error/length.rs | UTF-8 | 1,470 | 3.5625 | 4 | [
"MIT"
] | permissive | use crate::display::byte_count;
use crate::fmt;
/// Length that was expected in an operation.
#[derive(Copy, Clone, PartialEq, Eq)]
#[must_use]
pub enum Length {
/// A minimum length was expected.
AtLeast(usize),
/// An exact length was expected.
Exactly(usize),
}
impl Length {
/// The minimum len... | true |
30ad82d5b3986b4b524283ad28ddc9556d47109e | Rust | GustavoAdame/CSE262-Parser-Project | /src/runtime.rs | UTF-8 | 5,541 | 3.28125 | 3 | [] | no_license | use crate::parser::Node;
use std::collections::HashMap;
#[derive(Debug, PartialEq, Clone)]
pub enum Value {
String(String),
Number(i32),
Bool(bool),
}
struct Runtime {
functions: HashMap<String, Vec<Node>>,
stack: Vec<HashMap<String, Value>>,
}
impl Runtime {
pub fn new() -> Runtime {
Runtime {
... | true |
2c3c9bb059c114fc882499a2e2a654e808a9a08c | Rust | Ramdambo/climb-visitor-scraper | /src/main.rs | UTF-8 | 4,619 | 2.65625 | 3 | [] | no_license | extern crate chrono;
extern crate influxdb;
extern crate scraper;
extern crate serde;
extern crate thiserror;
extern crate tokio;
#[macro_use]
extern crate clap;
use chrono::{DateTime, Utc};
use influxdb::{Client, InfluxDbWriteable};
use scraper::{Html, Selector};
use serde::Deserialize;
use std::{fmt, fs, io};
use t... | true |
f38bf5265412350bb56ce6f34c0aa3553630f2cf | Rust | styrowolf/autolink-egui | /src/app/utils.rs | UTF-8 | 1,087 | 2.765625 | 3 | [
"MIT"
] | permissive | use eframe::egui;
use eframe::egui::Ui;
use crate::app::state::UIState;
use autolink_lib::{Plan, chrono};
use std::sync::{Arc, Mutex};
pub fn entry_selection_box(ui: &mut Ui, plans: Arc<Mutex<Vec<Plan>>>, selected: &mut usize) {
let plans = plans.lock().unwrap().clone();
egui::containers::ComboBox::from_label(... | true |
817eebdbc3f667491bf485fadbed50dec9795ddf | Rust | galenguyer/risp | /src/main.rs | UTF-8 | 704 | 2.796875 | 3 | [
"BSD-3-Clause"
] | permissive | use rustyline::error::ReadlineError;
use rustyline::Editor;
fn main() {
// create rustyline editor with no completer
let mut rl = Editor::<()>::new();
loop {
let readline = rl.readline("risp> ");
match readline {
Ok(line) => {
rl.add_history_entry(line.as_str())... | true |
f510122d76ec191f1bce93bfcbdd49aa0b9b81e9 | Rust | rust-lang/rustfmt | /tests/source/issue-5042/multi-line_comment_without_trailing_comma.rs | UTF-8 | 509 | 2.84375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | fn main() {
// 5042 deals with trailing commas, not the indentation issue of these comments
// When a future PR fixes the inentation issues these test can be updated
let _ = std::ops::Add::add(10, 20
// ...
// ...
);
let _ = std::ops::Add::add(10, 20
/* ... */
//... | true |
3730b9146fdf98d40a6125c443643237e5830cc2 | Rust | Aurametrix/Rust | /DATA/ll.rs | UTF-8 | 552 | 3.5625 | 4 | [] | no_license | pub struct Node {
value: u64,
next: Option<Box<Node>>,
prev: Option<Box<Node>>,
}
// must be mut to be modifiable
let mut head = Node {
value: 5,
next: None,
prev: None,
};
let next = Node {
value: 6,
next: None,
// next takes ownership of head!!!
prev: Some(Box::ne... | true |
685f092c38db9379fb6ff6f9666c88ddb1176fda | Rust | oliver-giersch/hazptr | /src/default.rs | UTF-8 | 2,255 | 2.65625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::ptr::NonNull;
use reclaim::typenum::Unsigned;
use reclaim::{GlobalReclaim, Reclaim};
use crate::hazard::Hazard;
use crate::local::{Local, LocalAccess, RecycleError};
use crate::{Unlinked, HP};
pub type Guard = crate::guard::Guard<DefaultAccess>;
// Per-thread instances of `Local`
thread_local!(static LOCAL... | true |
33d656e410ca8b3b3098979e08fae44a64fb7935 | Rust | szabo137/ptarmigan | /src/output/error.rs | UTF-8 | 762 | 3.375 | 3 | [
"Apache-2.0"
] | permissive | //! Output-related errors
use std::fmt;
use std::error::Error;
pub enum OutputError {
Conversion(String, String),
Dimension(usize),
Write(String),
}
impl fmt::Display for OutputError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
OutputError::Conversion(s, t... | true |
f55dac37606d884f2ab7e69f80ff1c581702eb84 | Rust | lnds/exercism_rust_track | /anagram/src/lib.rs | UTF-8 | 566 | 3.1875 | 3 | [] | no_license | use std::collections::HashSet;
use itertools::Itertools;
pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&'a str]) -> HashSet<&'a str> {
let sorted_word = word.to_lowercase().chars().sorted().collect::<String>();
possible_anagrams
.iter()
.filter(|s| word.to_lowercase() != s.to_lowerca... | true |
935e38b4958932d01ce1a770867e654904d75893 | Rust | LightAndLight/spiddy | /generate/src/lib.rs | UTF-8 | 1,462 | 3.1875 | 3 | [] | no_license | use ast::Expr;
const ALPHABET: &str = "abcdefghijklmnopqrstuvwxyz";
pub struct Generator {
idents: Vec<String>,
}
impl Generator {
pub fn new() -> Self {
let mut idents = Vec::new();
let alphabet: Vec<char> = ALPHABET.chars().collect();
for _ in 0..100 {
let length = (rand... | true |
6867210abd2afa8f86172c03917cfec662da5ee5 | Rust | GillesRasigade/rust-aco | /tests/colony_creation.rs | UTF-8 | 204 | 3.0625 | 3 | [] | no_license | extern crate ants;
use ants::colony::Colony;
#[test]
fn colony_creation() {
let colony = Colony::new(1.0, 2.0, 3.0, 4.0, 5.0);
assert_eq!(colony.alpha, 1.0, "Colony instanciation must be valid");
} | true |
a306ebaaedf53fc3e31e16badc9ea7382f733611 | Rust | pismute/exercism | /rust/isbn-verifier/src/lib.rs | UTF-8 | 683 | 3.359375 | 3 | [] | no_license | /// Determines whether the supplied string is a valid ISBN number
pub fn is_valid_isbn(isbn: &str) -> bool {
isbn.chars()
.try_fold((0, 10), |(acc, weight), x| {
match x {
_ if weight < 1 => None, // too long input
'-' => Some((acc, weight)), // skip
... | true |
acf4ff5ae72a773e9c98893f3febbce0348ffa08 | Rust | iwahbe/mapreduce-rs | /src/ccompat.rs | UTF-8 | 2,495 | 3.40625 | 3 | [] | no_license | pub mod carray {
#[no_mangle]
#[repr(transparent)]
/// Transparent wrapper on a C array to facilitate easy indexing and
/// iteration.
///
/// Does not take ownership of the memory it observes. Does not free memory.
///
/// ```
/// # fn get_c_array() { 0xFFF as *cont c_int }
/// ... | true |
a696a86d38baa43276ea907a8a841336e3b59499 | Rust | johanlindblad/advent-of-code-2018 | /src/day12.rs | UTF-8 | 4,261 | 2.9375 | 3 | [] | no_license | use std::boxed::Box;
pub type Pattern = (u8, bool);
pub struct Input {
initial: Vec<u128>,
patterns: Vec<bool>
}
fn parse_pattern(line: &str) -> Pattern {
let (lhs_s, rest) = line.split_at(5);
let (_, rhs_s) = rest.split_at(4);
let rhs = rhs_s.chars().next().unwrap();
let lhs = lhs_s
... | true |
ffa10fb53a9506ebe3a576aca9b1c55029784661 | Rust | dplewis/deno | /runtime/fs_util.rs | UTF-8 | 2,101 | 3.09375 | 3 | [
"MIT"
] | permissive | // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
pub use deno_core::normalize_path;
use std::env::current_dir;
use std::io::Error;
use std::path::{Path, PathBuf};
/// Similar to `std::fs::canonicalize()` but strips UNC prefixes ... | true |
5c6a0638938e815549dcbe664cb77ca87eebe05e | Rust | supabase/postgres_lsp | /crates/parser/src/syntax_node.rs | UTF-8 | 575 | 2.546875 | 3 | [
"MIT"
] | permissive | //! This module defines Concrete Syntax Tree (CST), used by postgres_lsp.
//!
//! The CST includes comments and whitespace, provides a single node type,
//! `SyntaxNode`, and a basic traversal API (parent, children, siblings).
//!
//! The *real* implementation is in the (language-agnostic) `cstree` crate, this
//! modu... | true |
bbae080b39f1da7781caf13b77a70524d455e7ce | Rust | hyperium/http | /tests/header_map.rs | UTF-8 | 17,352 | 3.25 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use http::header::*;
use http::*;
#[test]
fn smoke() {
let mut headers = HeaderMap::new();
assert!(headers.get("hello").is_none());
let name: HeaderName = "hello".parse().unwrap();
match headers.entry(&name) {
Entry::Vacant(e) => {
e.insert("world".parse().unwrap());
}
... | true |
60755c41f9195a577cc8078545b26c35a8791dc5 | Rust | qinxiaoguang/rs-lc | /src/solution/j057.rs | UTF-8 | 1,209 | 3.359375 | 3 | [] | no_license | use super::Solution;
impl Solution {
// 使用map
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut m = std::collections::HashMap::new();
nums.iter().for_each(|n| {
*m.entry(n).or_insert(0) += 1;
});
let mut res = vec![];
nums.iter().find(|&n| {
... | true |
33db001fc1fc84ebdf01ccc4397969713771865f | Rust | Owen66/crawler | /src/handlers.rs | UTF-8 | 2,025 | 2.84375 | 3 | [] | no_license | use warp::{Reply, Rejection, reject};
use warp::http::StatusCode;
use serde_derive::{Deserialize, Serialize};
use crate::crawler::crawl;
use deadpool_postgres::Pool;
use url::Url;
use crate::db;
use crate::error::Error::{UrlParseError};
use crate::error::Error;
#[derive(Deserialize, Serialize)]
pub struct Domain {
... | true |
965f168de06191b6bd49fb9aae1fe10eb867cc59 | Rust | mattsse/crossref-rs | /src/lib.rs | UTF-8 | 25,066 | 3.515625 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | //! This crate provides a client for interacting with the crossref-api
//!
//! [Crossref API docs](https://github.com/CrossRef/rest-api-doc)
//! `Crossref` - Crossref search API. The `Crossref` crate provides methods matching Crossref API routes:
//! * `works` - `/works` route
//! * `members` - `/members` route
//! * ... | true |
db0f802be062b699b37380a913b6df1b49f2e509 | Rust | wood1986/baccarat | /src/main.rs | UTF-8 | 9,251 | 2.796875 | 3 | [] | no_license | extern crate rand;
extern crate num;
const COUNTING_FACTORS: [[i8; 10]; 10] = [
[-3, 2, 2, 2, 2, 1, 1, 0, 1, 1],
[-1, -6, 2, 2, 2, 2, 1, 1, 0, 0],
[-1, -1, -6, 2, 2, 2, 2, 1, 2, 0],
[-1, -1, -1, -6, 2, 2, 3, 3, 0, 2],
[ 0, -1, 0, 0, -6, 1, 2, 2, 2, 0],
[ 0, 0, -1, -1, ... | true |
49101cfcc26d6794ee71827d818fa32c8e4b50e7 | Rust | paritytech/ink | /crates/ink/tests/ui/blake2b/pass/string_input.rs | UTF-8 | 586 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | use ink_ir as ir;
macro_rules! assert_macro_eq {
( $input:literal ) => {{
// We put it into a constant to verify that the computation is constant.
const HASH: [u8; 32] = ink::blake2x256!($input);
assert_eq!(
HASH,
{
let mut output = [0u8; 32];
... | true |
66956dfb2954b577f3feef2763cdfabfafe0d828 | Rust | SuanFaRuoJi/coding_exercise_rust | /src/kth_smallest_elements_in_a_bst_230.rs | UTF-8 | 828 | 3.015625 | 3 | [] | no_license | use std::rc::Rc;
use std::cell::RefCell;
use super::ds::TreeNode;
use std::borrow::{BorrowMut, Borrow};
pub fn kth_smallest(root: Option<Rc<RefCell<TreeNode>>>, k: i32) -> i32 {
let arr: Vec<i32> = flatten(root);
println!("{:?}", arr);
return arr[k as usize];
}
fn flatten(head: Option<Rc<RefCell<TreeNode>... | true |
37ebdc36ca936fbf8327f379b49666e8b48f817d | Rust | nickolay/git-interactive-rebase-tool | /src/git/src/testutil/with_temp_repository.rs | UTF-8 | 1,728 | 2.53125 | 3 | [
"BSD-3-Clause",
"GPL-3.0-only",
"Apache-2.0",
"BSD-2-Clause",
"GPL-3.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later"
] | permissive | #![cfg(not(tarpaulin_include))]
use std::path::Path;
use tempfile::Builder;
use crate::{testutil::JAN_2021_EPOCH, Repository};
pub(crate) fn with_temporary_path<F>(callback: F)
where F: FnOnce(&Path) {
let temp_repository_directory = Builder::new().prefix("interactive-rebase-tool").tempdir().unwrap();
let path = ... | true |
ee243996d4f1b36b0caef2c1bf56d96458014b15 | Rust | fyrros/taubox | /rust/confgen/src/logic.rs | UTF-8 | 4,512 | 2.90625 | 3 | [] | no_license | use yaml_rust::Yaml;
use std::collections::{HashMap, BTreeMap};
#[derive(Debug)]
pub struct LogicManager<'a> {
auto_include: Vec<LogicScript>,
folders_order: Vec<&'a str>,
}
impl<'a> LogicManager<'a> {
pub fn new() -> LogicManager<'a> {
LogicManager {
auto_include: Vec::new(),
... | true |
184f9ea5944189739e18deef541b168e62010660 | Rust | coffee-cup/shortener | /src/repository.rs | UTF-8 | 1,995 | 3.21875 | 3 | [] | no_license | use crate::shortener::Shortener;
use std::{collections::HashMap, env};
use redis::Commands;
pub trait Cache {
// Store an entry and return an ID
fn store(&mut self, data: &str) -> String;
// Look up a previously stored entry
fn lookup(&mut self, id: &str) -> Option<String>;
}
pub struct MemoryReposi... | true |
e64b4ec1ad0a6e882122629d29c132da46ba876d | Rust | andrewflbarnes/advent-of-code-2020 | /08/solution2.rs | UTF-8 | 1,878 | 3.03125 | 3 | [] | no_license | use std::env;
use std::fs;
mod operations;
use operations::{
OpCode,
State,
};
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let data = fs::read_to_string(filename)
.expect(&format!("Could not open file: {}", filename))
.lines()
.m... | true |
af26c6d7f06d3b4786cdf85e40bcbc6770a1882a | Rust | eranfu/leetcode | /examples/5850_找出数组的最大公约数.rs | UTF-8 | 669 | 3.8125 | 4 | [] | no_license | //! [5850. 找出数组的最大公约数](https://leetcode-cn.com/problems/find-greatest-common-divisor-of-array/)
impl Solution {
pub fn find_gcd(nums: Vec<i32>) -> i32 {
let mut min = i32::MAX;
let mut max = i32::MIN;
for x in nums {
if x > max {
max = x;
}
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.